Search code examples
ioscordovafirebaseapple-push-notificationsphonegap-pushplugin

phonegap push notification works on android but not on ios


As the title says Push notification works fine on android but on IOS it does not. push.on(registration...) is never called. I have made sure that provisional profiles are valid for both development and distribution. I am using firebase for cloud messaging.I am looking for any sort of guidance on how to fix this.

Here is the console out put:

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);

Solution

  • I fixed it by skiping firebase all together and going straight to APNS