-
Notifications
You must be signed in to change notification settings - Fork 1.9k
notification event not called on ios #414
Comments
Why are you fetching the plugin's code from the internet, since they are already available locally from cordova? |
Thanks for the quick reply :) I'm fetching my event handlers code from the internet so it will always be up-to-date and so I could fix bugs without rebuilding the APK. I'm using it in my multiplayer gaming platform: I think I'll solve it by also saving some code in localStorage, to avoid "missing" notifications: It's just weird it's happening only on iOS (and not on Android). But maybe Android is slower to fetch the notifications, so I never saw it happening on android. |
I mean, I can understand if you're getting the following code from outside: var push = PushNotification.init(...)
push.on('registration', ...);
...
...
... But by "I fetch the phonegap JavaScript code from the internet" I inderstood that you're actually fetching the plugin's code from the internet too, and that's not good (if that's indeed the case). You don't need to set up your handlers immediately. As soon as you set them up, if a cached message is present, it'll be sent to your handlers no matter when you register them. The only soft requirement is that handlers are registered in the same CPU cycle that you call //this is okay
var push = PushNotification.init({...});
push.on('notification', function(){...});
//this is not
var push = PushNotification.init({...});
setTimeout(function() {
push.on('notification', function(){...});
}); |
Thanks, this is saving me a lot of time :) Yes, I'm doing it in the same CPU cycle. Happy to know the notification is cached until I call init :) I've done some more experiments and the problem is only on iOS when the app is closed.
That's why I still suspect it's either:
I use this version: BTW, on Android, the use-case I'm talking about is when: BTW, after looking at your code I realized that notId is an INTEGER (not LONG): |
The version I used got truncated/removed because github removed html elements :) |
BTW, I changed the notId to be an int, but the issue still happens on iOS. I summarized the problem below. Full example for foreground message: Full example for background message: Full example for coldstart message: Note that coldstart field is completely missing from iOS (for the case of background message, on Android, I have "coldstart":false, but that doesn't exist on iOS). |
Yes, more than a suspicion --- iOS doesn't handle coldstart (I love open source --- I can just search the code :)) How am I supposed to handle coldstart? |
So, you're using Phonegap Build now supports gradle builds, so could you try and upgrade your plugin to the latest one and retest? |
But I searched the code and I only see "coldstart" in Android code: |
Emm, I have problems upgrading to version 1.3. Do you have an example of config.xml that works on phonegap build? I removed all other plugins, I updated the plugin to 1.3, and I even set: The error I get: In the build logs: Error: Project contains at least one plugin that requires a system library. This is not supported with ANT. Please build using gradle. In phonegap build docs, they only mention minSdkVersion and grade: |
Please add this to your <preference name="android-build-tool" value="gradle" /> |
Ok, upgraded successfully to latest version: But the notification handler is no longer called :( I tried it twice (7:50 and 7:59): PushNotification registration: Object device token = fQ3Dg8_jcmM:APA91bEFChZPmKPOD9wjWzj8kxGQ75AVyfYZ0rs4EIt51fByS4yH65XcI5hCrSqjflcLzlXO7y_FAWXX3MdbNvM3acLLG3LZ6YcstTGA2VyWMnXGm6bWtmrKp3JvACYnGUfhy6H2hAUM platformType= ANDROID On the server side I see that it was sent: On Google Play, the notifications now look different: Any idea why? Again, I created a bug report (like I did for #419), but I don't want to attach it publicly. Happy to email it :) |
I think I have two versions of GCMIntentService running. I'm removing now all other plugins to see if maybe it's caused by another plugin... From my bug report:
2015-12-14 08:23:09.992 |
No luck --- removed all plugins (except org.apache.cordova.splashscreen, cordova-plugin-whitelist, and phonegap-plugin-push) and still no notifications. Oh, I think I found it! 12-14 07:59:40.517 1938 2514 D WifiStateMachine: starting scan for "FiOS-SZ05D"WPA_PSK with 5825,2462 When I send the notification, I set: I'll remove it to use the default icon |
Yippie, after removing it, android is working fine :) I couldn't figure out a way to test ios locally on my iphone4, so I'll just submit it to apple and hope for the best, and then test it in production (in 1-2 weeks). I'll update the bug on whether coldstart is working on ios. |
@yoav-zibin there is no coldstart for iOS that is an Android GCM supplied piece of data. |
BTW, finally confirmed that coldstart is working correctly for me on ios using v 1.4.5 (I don't get the coldstart boolean flag, but I can manage without it --- at least I'm getting the notification-handler called :)) (Note that it didn't work in v 1.2.3) Thanks! |
This thread has been automatically locked. |
Hi,
First, thanks for the awesome plugin!
My issue is that the notification event is not getting called on ios (but it works perfectly fine on android).
The exact scenario:
I see the push notification, and click on it. This opens the app, but notification event is not getting called on iOS.
Do I need to call
push.on('notification', ...
immediately when the app starts, even before I get the deviceready event?
Because, in my app, I fetch the phonegap JavaScript code from the internet, so I call
push.on('notification', ...
only a couple of milliseconds after deviceready. So I'm afraid that maybe I "missed" the notification.
I don't understand though why I don't "miss" the notification on Android...
I'm not using background notifications.
The text was updated successfully, but these errors were encountered: