phonegap推送通知适用于Android但不适用于ios

时间:2017-03-23 14:49:06

标签: ios cordova firebase apple-push-notifications phonegap-pushplugin

正如标题所说,推送通知在Android上运行正常但在IOS上没有。 push.on(注册...)永远不会被调用。我确保临时配置文件对开发和分发都有效。我正在使用firebase进行云消息传递。我正在寻找有关如何解决此问题的任何指导。

这是控制台输出:

2017-03-23 16:15:49.741405 [342:34586] Push Plugin register called
2017-03-23 16:15:49.741515 [342:34586] PushPlugin.register: setting badge to false
2017-03-23 16:15:49.741559 [342:34586] PushPlugin.register: clear badge is set to 0
2017-03-23 16:15:49.752879 [342:33926] Push Plugin register success: <######## ######## ######## ######## ######## ######## ######## ########>

          document.addEventListener("deviceready", function() {
                var push = PushNotification.init({
                     android: {
                        senderID: "############",
                        forceShow: true
                     },
                     ios: {
                        sound: true,
                        alert: true,
                        badge: true
                     }
                    });


                push.on('registration', function(data) {
                    console.log('GCM: ' + data.registrationId);

                    $rootScope.pushRegStatus = true;

                    $rootScope.registerPushOnServer(data.registrationId);
                });

                push.on('notification', function(data) {
                    // data.message,
                    // data.title,
                    // data.count,
                    // data.sound,
                    // data.image,
                    // data.additionalData
                    // console.log('notification' + data.toString());

                    // App started by clicking on push notification ..
                    // if(data.additionalData.coldstart === false || data.additionalData.coldstart === true) {
                        // $location.path('/pushLog/' + data.additionalData.push_log_id);
                    // }

                    // Got notification while app is in foreground ..        
                    if(data.additionalData.foreground) {
                        //$rootScope.alert(data.title, data.message);
                    } else {
                        $rootScope.alert(data.title, data.message);
                        // $location.path('/pushLog/' + data.additionalData.push_log_id);
                        $rootScope.openPushLogFromNotification = true;
                        // setTimeout(function() {
                        //     $rootScope.openPushLogFromNotification = false;    
                        // }, 3000);

                        $location.path('/pushLog');
                    }
                });

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

              }, false);

1 个答案:

答案 0 :(得分:1)

我通过一起滑动firebase并直接进入APNS来修复它