Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Background notification does not working in 1.4.x #324

Closed
ray-systems opened this issue Nov 11, 2015 · 15 comments
Closed

Background notification does not working in 1.4.x #324

ray-systems opened this issue Nov 11, 2015 · 15 comments

Comments

@ray-systems
Copy link

For Android 5.0 with phonegap-plugin-push 1.4.2 - notification background is not working, but 1.3.0 is fine working... When app is open, did not get any notification, after closed app (minimzed) and clicked notification that push.on('notification') is fired. Anyone has the same problem?

Now I am working with phonegap-plugin-push 1.3.0...

@stinju
Copy link

stinju commented Nov 11, 2015

If I understand correctly, I believe I am having the same issue. On android, when the app is in the background, an incoming notification will trigger GCMIntentService.onMessageReceived, buzz the app, open the app, but will not trigger my listener (via push.on('notification') in js) to the "notification" event.

@stinju
Copy link

stinju commented Nov 11, 2015

FYI, downgrading to 1.3.0 also seems to resolve the issue for me.

@macdonst
Copy link
Member

I'm not sure that I understand your problem. Here is the way it should work.

App Open

With the app open your on('notification') event handler will always be called. You will not see anything in the notification shade unless you set options.android.forceShow to true.

App in Background

With the app open you will see a notification in the shade as long as your payload from GCM has a title or message component. Your on('notification') will not be called in this case. If the user clicks on the notification in the shade your app will start and your on('notification') event handler will be called.

If you do not provide a title/message in the payload from GCM then your on('notification') event handler will be called as it is assume this is a silent or data only notification.

App Close (ie not running)

You are pretty screwed at this point. Need to work on some code to restart the GCM service if the app is killed.

Please let me know if you are running into a problem in any of the above scenarios or if you have a new scenario.

@stinju
Copy link

stinju commented Nov 11, 2015

This is what is not true for me with 1.4.2 on android only, in the "App in Background" bucket:

If the user clicks on the notification in the shade your app will start and your on('notification') event handler will be called.

The app starts, but the event handler is not called. Not completely sure that is the same scenario as sonrebmax.

@stinju
Copy link

stinju commented Nov 11, 2015

Also, note that if the app is not in the background (no instance running), clicking on the notification in the shade will open the app and in fact call the notification event handler correctly. The issue I have is strictly when the app is in the background. I'm using a Moto G on Android 4.4.4, Cordova Android 4.1.1, phonegap-plugin-push 1.4.2.

@ray-systems
Copy link
Author

App Open

With the app open your on('notification') event handler will always be called. You will not see anything in the notification shade unless you set options.android.forceShow to true.

I done with this options.android.forceShow to true. As I wrote working fine in 1.3.0 not in 1.4.x (I checked 1.4.0 and 1.4.2)

@stinju
Copy link

stinju commented Nov 11, 2015

@sonrebmax is your issue when the app is open or when the app is in the background? If we are talking about different things, I'll create a separate thread.

@ray-systems
Copy link
Author

I wrote

.. When app is open, did not get any notification, after closed app (minimzed) and clicked notification that push.on('notification') is fired.

@stinju
Copy link

stinju commented Nov 11, 2015

Would you be able to elaborate on that statement a little bit? Might help me (and maybe @macdonst) understand a little bit more.

Either way, at this point, I will create a separate thread, so as not to add any confusion.

@ray-systems
Copy link
Author

@macdonst do you understand what I mean? (my english is not good)

@ray-systems
Copy link
Author

App Open
With the app open your on('notification') event handler will always be called. You will not see anything in the notification shade unless you set options.android.forceShow to true.

in 1.3.0 = OK
in 1.4.2 = does not working - only showing push notification (on('notification') not called in app, so I must to click a push notification then on('notification') is called

App in Background
With the app open you will see a notification in the shade as long as your payload from GCM has a title or message component. Your on('notification') will not be called in this case. If the user clicks on the notification in the shade your app will start and your on('notification') event handler will be called.

in 1.3.0 = OK
in 1.4.2 = OK

If you do not provide a title/message in the payload from GCM then your on('notification') event handler will be called as it is assume this is a silent or data only notification.

in 1.3.0 = does not working
in 1.4.2 = OK (interesting feature)

@ballenjr
Copy link

Hello @macdonst,

I am trying to prove/use your comment and the readme instructions regarding silent notifications.

I think that some of the confusion may be coming from the various server side implementations.

For instance: the problem that I am having is that when I pass notification: {}, which is where I normally put my title and message properties, I am not getting the onnotification to fire while my app is running, on the other side, in the background.

Can you offer any clarification as to what else may be happening when gcm takes this format or the proper format that gcm will properly deliver? My server logs indicate that it is accepted but since I never get anything back I am unsure if it was mangled somehow to prevent final delivery.

Or any insight within the assumption that gcm did perform final delivery and this plugins expected final result was what got mangled during transit?

Or any expectations in between those possibilities.

@ballenjr
Copy link

Nevermind, it appears that the issue was related to other conflicts that I monkey patched with stuff like library overrides. I got rid of the conflicting playservices plugin and now everything is working as it should.

@ZoRDoK
Copy link

ZoRDoK commented Feb 26, 2016

Same problem - silent notifications not received with 1.4+

I post them with curl string from google docs - successfull answer but nothing on phone.

@lock
Copy link

lock bot commented Jun 4, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

5 participants