Hello, I have the problem, that on iOS the "push-notification" event is not fired. When I click on the received the notification, the App ist starting (if it was closed/in background), but not reacting on the event.

The debugging does not show the logs which I should see after opening the notification. I use Ionic for building my apps and the PushWoosh PhoneGap Build Plugin.

On Android it is working without any problems.

I followed the instruction given on the PushWoosh documentation:

function initPushwoosh() {
var pushNotification = cordova.require("pushwoosh-cordova-plugin.PushNotification");

//set push notification callback before we initialize the plugin
document.addEventListener('push-notification', function(event) {
                            $log.debug('PushWoosh: ', event);
                            //get the notification payload
                            var notification = event.notification;

                            //display ionicPopup to the user
                            var myPopup = $ionicPopup.show({
                                template: '<p>'+ event.notification.title +'</p>',
                                title: '<b>Neuigkeiten</b>',
                                scope: $scope,
                                buttons: [
                                    { text: 'Schließen' }
                                ]
                            });

                            //clear the app badge
                            pushNotification.setApplicationIconBadgeNumber(0);
                        });

//initialize the plugin
pushNotification.onDeviceReady({pw_appid:"PUSHWOOSH_APP_ID"});

//register for pushes
pushNotification.registerDevice(
    function(status) {
        var deviceToken = status['deviceToken'];
        console.warn('registerDevice: ' + deviceToken);
    },
    function(status) {
        console.warn('failed to register : ' + JSON.stringify(status));
        alert(JSON.stringify(['failed to register ', status]));
    }
);

//reset badges on app start
pushNotification.setApplicationIconBadgeNumber(0);
}

And I call the method initPushWoosh() in the $ionicPlatform.ready(function...

What am I doing wrong?

asked 18 May '16, 13:00
Fabian's gravatar image

Fabian
113

edited 18 May '16, 13:01

The problem was, that I called the initPushWoosh method within a service. Now the method is directly in the $ionicPlatform.ready function and so I don't get any Problems.

permanent link
answered 19 May '16, 15:46
Fabian's gravatar image

Fabian
113

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×353
×165
×91
×14

question asked: 18 May '16, 13:00

question was seen: 1,543 times

last updated: 19 May '16, 15:46