简体   繁体   English

接收推送通知后,从javascript导航到ionic中的特定页面

[英]Navigate to particular page in ionic from javascript after reciving push notification

I am writing a push notification receiver using phonegap push plugin .All things working fine i am receiving push notification from server but the problem is when i clicked on notification received it redirects me to my application home page instead of that i want it should redirect to notification detail page .I am using ui-router in my app all state are configured properly but i dont know how to call a ui-route from external javascript. 我正在使用phonegap push插件编写一个推送通知接收器。一切正常,我正在从服务器接收推送通知,但问题是当我单击收到的通知时,它将我重定向到我的应用程序主页,而不是我希望它重定向到通知详细信息页面。我在我的应用程序中使用ui-router,所有状态均已正确配置,但我不知道如何从外部JavaScript调用ui-route。

   var connectionStatus;
     var push;
    var app = {
// Application Constructor
initialize: function() {
    this.bindEvents();
},

bindEvents: function() {
    document.addEventListener('deviceready', this.onDeviceReady, false);
},
 onDeviceReady: function() { 

     push = PushNotification.init({
            "android": {
            "senderID": "XXXXXXXX",
             "iconColor": "red"
        },
        "ios": {"alert": "true", "badge": "true", "sound": "true"}, 
        "windows": {} 
    });

    push.on('registration', function(data) {

        console.log("registration event");

        console.log(JSON.stringify(data));
         angular.element(document.body).injector().get("RegistrationService").post_reg(data.registrationId);

    });

    push.on('notification', function(data) {
        console.log("notification event");
        console.log(JSON.stringify(data));
        //here i need to navigate to notification detail page 
    });

    push.on('error', function(e) {
        console.log("push error");
    });


    }
 };

 app.initialize();
push.on('notification', function(data) {
    console.log("notification event");
    console.log(JSON.stringify(data));
    $location.url('url') 
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM