离子手柄推送通知

时间:2016-12-29 10:24:08

标签: android angularjs ionic-framework

我已收到使用FCM插件的推送通知。当我点击通知时,应用程序启动画面已打开,但我打开另一个屏幕。我该怎么做?请帮忙。

app.js

.run(function ($ionicPlatform, $rootScope, $state) {
$ionicPlatform.ready(function() {
    if(window.cordova) {
        FCMPlugin.onNotification(
            function(data){
              $rootScope.notificationData = data;
                    $rootScope.reciveMessage(data);
                        $state.reload();
                if(data.wasTapped){
                   // $state.go('message', {id:data.pageId});
                  // $location.path('app/userList');
                    console.log('onNotification tapped true');
                } else {
                    console.log("xxxxxxxxxxxx"+data.message);
                }
            },
            function(msg){
             // alert("asdf"+msg)
                console.log('onNotification callback successfully registered: ' + msg);
                FCMPlugin.getToken(
                 function(token){
                   //alert(token);
                   window.localStorage.setItem("deviceId",token)
                 },
                 function(err){
                   console.log('error retrieving token: ' + err);
                 }
               )
            },
            function(err){
             // alert("fjkjg"+err)
                console.log('Error registering onNotification callback: ' + err);
            }
        );
    }
});

})

0 个答案:

没有答案
相关问题