phonegap-build / PushPlugin

This repository is deprecated head to phonegap/phonegap-push-plugin
https://github.com/phonegap/phonegap-plugin-push
MIT License
1.31k stars 996 forks source link

iOS ecb callback not firing with PushNotification plugin #68

Open aaroncraigongithub opened 11 years ago

aaroncraigongithub commented 11 years ago

I've done a full write up of the problem on the PG Build forum, as I assumed to begin with that this was an issue with Build.

They have directed me to post an issue here, though, so here you go :)

http://community.phonegap.com/nitobi/topics/ios_ecb_callback_not_firing_with_pushnotification_plugin

The summary of the post is: Using more or less the boilerplate example, everything works as expected on Android. iOS calls the token handler, but does not call the ecb callback. If the app is in the background the notice is displayed in the notification area or the lock screen on iOS, but activating the app still doesn't cause the ecb handler to run.

JWesorick commented 9 years ago

+1 Experiencing same behavior as @mmacmillan

aBuder commented 9 years ago

+1 Experiencing same behavior as @mmacmillan an @JWesorick

clarklight commented 9 years ago

@aBuder @JWesorick I am wondering if you are talking about that onResume issue, that it does not pull in the push notification into the App,(No ECB when onResume when app icon is clicked). As i am facing that problem, i read that on version 2.4.0 thats not an issue anymore. But i dont seem to read anywhere on documentation about how to handle onResume(either by clicking the App icon, or from Android).

gopaulo commented 9 years ago

+1 Experiencing same behavior as @mmacmillan an @JWesorick and @aBuder

IqraRastee commented 9 years ago

+1 Experiencing same behavior

mrameezraja commented 9 years ago

Try making your ecb callbacks global for ios and android. i.e window.onNotificationAPN = function(){ ... } window.onNotification = function(){ ... }

farshidbeheshti commented 9 years ago

Try making your ecb callbacks global for ios and android. i.e window.onNotificationAPN = function(){ ... } window.onNotification = function(){ ... }

Yeah, that should solve it!

Farshid

OleksandrPoltavets commented 9 years ago

window.onNotificationAPN = function(){ ... }

mrameezraja, You are genius! Thanks, this works on iOS for me.

fahimehr commented 9 years ago

Making it a global function doesn't fix the issue for me. any other solution?

mrameezraja commented 9 years ago

Can you share your code ?

addityasingh commented 8 years ago

I have found the solution for this one. The reason for this issue is that in PushPlugin.m the callback property is set to nil on killing the app. As a result, the check on line#202 is not satisfied in the - (void)notificationReceived callback. The fix for the issue is to instantiate the PushPlugin class on opening the push notification every time your app starts. This can be done by registering the push notification plugin on app start. Call the pushNotification.register method in your javascript everytime your app starts, and this will instantiate the plugin and assign the appropriate callback the plugin. I have added the below code to my Ionic app's app.run() section

window.plugins.pushNotification.register(successCallback, errorCallback, {
        badge: 'true',
        sound: 'true',
        alert: 'true',
        ecb: 'window.onNotificationAPN'
})

Let me know if anyone still faces this issue.

lampofdrog commented 8 years ago

@mrameezraja ur solution fixed the problem thx !