-
Notifications
You must be signed in to change notification settings - Fork 1.9k
"Notification" Event Not Firing When Closed Through App Launcher #158
Comments
Is this on Android? |
Yea, I'm testing this on Android 5.1.1 on a Nexus 5. I also tried reregistering the device on cold start which fixes the future |
@ryanpager after you force close the app do you still see the new push messages in the notification shade? |
@macdonst Oddly enough yea -- push notifications still work exactly as expected, they just dont trigger the 'notification' event regardless of if the app is in foreground or background. I also get them if the phone is completely asleep / locked (show up on the homescreen like normal). |
@ryanpager Okay, that's actually the behavior I would expect. When you close the app through the app launcher you are effectively killing your app so the on('notification') handler has been removed. I'm going to look at waking up the app on incoming notifications in the future but for now this is not handled. PR's on this topic are welcome. |
@ryanpager I am also having similar issue and using phonegap build so can you tell me how you able to receive notification even after force close. |
@app2naklabs I just installed the plugin and registered it like normal. But I am not using phonegap, its a cordova+ionic setup (which i dont think makes too much of a difference). The only different thing im doing is that im re-registering the device on coldstart. The push notification setup is AWS SNS (Amazon) => GCM (Google) => Phone. I havent tried any of this on iPhone yet. |
Can you please tell me how you are doing that; because when app is completely closed and not in used then in between if any notification is triggered then its not appearing in my device. So If you can tell me what changes you made in .js file that helped you in getting this issue solved. I am using phonegap build for building my app. |
@app2naklabs I dont know how to explain this any better. I am 100% using the stock plugin, with no extra configuration settings, and literally no changes to any file. It just works right out of the box the way I said it does. The only difference between yours and mine is that im using cordova/ionic versus phonegap. Sample Code: settings =
android:
senderID: xxxxxxxxxxxxxx
ios:
alert: yes
badge: yes
sound: yes
# Create instance
pushInstance = PushNotification.init(settings)
# Handle different events
pushInstance.on 'registration', _onRegistration
pushInstance.on 'notification', _onNotification
pushInstance.on 'error', _onError Plugin Version: 1.2.3 |
From my point of view: And yes I am also using Stock Plugin 1.2.3 except I did some customizing on Android for Parse.com which can be read here: #147 (but I think this customizing has nothing to do with working on notification trigger on Android cold start) UPDATE: |
@ryanpager Facing a similar issue. The |
+1 |
Using ionic here. Experiencing similar issue when quitting the app in ionic regardless of whether i quit through task manager or through the program close. I have a login in my app so it needs to check auth first before redirecting to the relevant page based on the notification that was clicked. The actual handling of notificationReceived is in the controller after login. Does register/init need to happen before notificationReceived, if the device was already registered in a previous session? |
++ |
Is this enhancement already done? |
Thanks @macdonst. I get nothing on android (not even a system notification) on a Zenfone 2, Android 5.0 stock rom. this is the logcat:
https://github.com/phonegap/phonegap-plugin-push/issues/748 |
I fixed my issue.. I was sending everything on Data.. that only works when the app is running. I filled the notification object and now it works flawlessly. Thanks @macdonst . |
+1 for notification triggers when app is closed |
+1 for notification event in JS when the app is killed/terminated. I found this (restarting the MainActivity if the WebView is not started) somewhere, maybe you could utilise a similar approach? |
@haclairvoyant i am not tried with the latest version..my point is notification event triggered when user click on notification |
@haclairvoyant no, there is no solution for this currently. If the user kills you app you will not get the JS event fired. There is one possible way to fix this but it requires a change in cordova-android that I'm trying to get in. |
This issue was solved? |
i have same issue. |
I have same issue on iOS. Exists good alternative for this plugin? |
Same issue on Android 6.0 & iOS 8.1.3. Any solution with Ionic + Cordova? Thank you |
Does anyone know that other plugin can do this type of notification? |
If the app is is in the background and swiped away in Android you need to send ("conent-available': 1) in the payload. This will wake up the app and run the notification callback. It will also work once you restart the phone as your app will still be in the background. |
…ncher * Use Cordova-Android 6 for start in background feature * Finish start in background
…ncher * Use Cordova-Android 6 for start in background feature * Finish start in background * Update docs
Okay, if you use cordova-android 6.0.0 or greater and grab the latest from master then you should be able to send |
I've seen Release 1.9.0 introduced the I confirm this is still an issue on latest iOS. Notification is not processed when application was "killed". Even combined with |
I don't mean to hijack the topic, but I would like help in understanding whether I actually need to use On a native Android application, I would expect a couple of important things: (1) After a device restart, it's possible to configure the GCM Service to start up on device boot. This means that the application code can handle the notifications even if the user hasn't started the app from the launcher since boot. (2) If the user backgrounds the app, then even if the associated Now, when it comes to an Ionic application using this library, the things I would like to know are: (1) When the Ionic application is "in the background", presumably the OS may eventually kill it. But, will the push callback still stay around in a Service? Or, do I need to rely on (2) Do I need to also rely on EDITI now have a better understanding, so don't need answers to the above. The answers I've determined are: (1) I continue to assume that a backgrounded Cordova app will live for a long time, but may at some point be killed. This is just my assumption. Therefore I do rely on the (2) Yes. If the user has never started the app, then again All of this is based on Android experience only so far. I've not yet dealt with iOS. |
@macdonst Hi Simon! Is this new feature Btw, thanks for this plugin and the very hard work! NB:
EDIT I did need to use |
@VinceOPS I'm successfully using (As an aside while I'm here, I encourage anyone using force-start to see this issue I raised, which highlights that you must be really careful that your Android really has been properly updated: #1402 (comment)) |
@VinceOPS Another way of putting it, is that even when https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md So, The reason I personally don't have a title or message is because I only want my callback to handle the message; I don't want automatic local notifications from the push library. However these don't affect whether the callback is called (contrary to what I said above). Hope that helps :) |
@TrevorPage: Hi! Thanks for your answer. Unfortunately, I do need to pass a title/message with this push notification... Yup I checked again and I'm pretty sure that my cordova-android is up to date, with the proper MainActivity! Ok, saw your new post in live. The GitHub team is doing things properly right? :P. Thanks again ;) |
@VinceOPS Just to ensure you noticed it, beware that I've corrected my earlier wrong comment about the title/message. Whether or not these are present do not affect whether the callback is called; only Having a I, personally, omit the title and message from the notification because I don't like this behavour. For reasons specific to my application, I always want the notification to be processed by my own code before any local notification is issued. Therefore, I use If for your purposes you are happy for a push notification from the server to always directly cause a local notification based on the message/title when the app isn't in foreground (i.e. it's background or being force-started into background) then you could make use of message and title. |
Yup, just noticed that Thanks again! |
@serneelsalexis Regarding your observation on iOS, is there any possibility that you have the iOS equivalent to the problem I had here: #1402 (comment) In other words, rebuild the iOS platform using the very latest platform version? |
@TrevorPage , cordova-ios doesn't have that same feature available yet (start on background). I may be wrong though, it's been a week since I caught up on the dev mailing list. |
… App Launcher * Use Cordova-Android 6 for start in background feature * Finish start in background * Update docs
I can confirm that force-start feature is working great on Android. Will this be available in ios? To be clear, I am referring to the force-start ability for a push notification to start the app when the app is not running (like after a reboot). It does not matter too much if it opens the app in the foreground or in the background, although opening it in the background would be preferable. |
So this is the use case im following:
a. Push notification goes to phone
b. User clicks on notification from lock, which opens the app & triggers the 'notification' event
c. Do some obligatory action based on additionalData
This is working perfectly, except it seems like the 'notification' event does not get triggered ever again if the user closes the application through the app launcher (square button & swipe) and the app has to coldstart.
So a run down of the problem in short:
a. User opens application, push is registered.
b. 'Notification' events now get triggered as expected.
c. User closes the application through the app launcher.
d. 'Notification' events no longer get triggered....ever.
Any ideas on this one?
The text was updated successfully, but these errors were encountered: