-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[android] onMessageReceived not being called when app not in foreground #515
Comments
Let me guess: you're sending your notification payload with all important fields (message, icon, style, etc) on the |
@AdriVanHoudt yeah, I'm willing to be that @fredgalvao has come across the root cause of the problem. If you put everything in the |
This appears to be fixing it thanks! Any reason why this was working before? Also @macdonst you put a milestone on this issue, can I ask why? |
You probably wasn't using the new GCM way of doing things (introduced a few versions ago on this plugin) when "things were working". That's my bet. The milestone thing is for the docs, this topic has been a often-reported one and needs to be better documented. |
I was using version 1.4.2 at least and it failed on 1.4.5 so did a change happen there somewhere? |
@AdriVanHoudt it seems like |
yeah weird, but it is fixed now for me so no hurry. I'll close this since it is fixed but we can still talk on on the why 😃 |
@AdriVanHoudt I'm going to re-open it as it will remind me document it for the next release. |
Np 👍 On Thu, 21 Jan 2016 15:26 Simon MacDonald [email protected] wrote:
|
I'll just add a little bit on this just to get a clear idea, because I have somewhat of a related problem (I guess I may have missed something, though). On Android 5.x :
Upon push, OS takes hand, displays local notification, never passes hand to my handler defined as :
This is never called, whether or not app is in foreground. Tapping the OS's notification does not bring front my app either. What am I doing wrong ? (I would be perfectly happy if my payload was not long enough to be truncated by local notification) Thanks |
Not really wrong, but the answer to that question is:
As mentioned by @macdonst and on quite a few issues recently, if anything appears on the All of this is documented in the GCM website, but we still need to mention it on our docs, hence the issues recently created. |
So basically it means that the following scenario is not possible ?
I would be happy with Android taking care of everything all the time if the notification area could display more than one-line messages, but it doesn't :( |
if you send on data property and you can handle it however you want, when your js event is triggered you can see if the app was in back/foreground and react based on that |
If I only use data, doesn't this mean that when OS takes over when app is in background, it will create a native notification with pretty much anything in it, since I didn't properly setup notification section ? |
Afaik when you only use data, the os will pass it onto the plugin which will make the notification |
But of course this will only take place if app is foreground, so you won't be notified in realtime when app is background, right ? |
It will make the notification and the moment you click it it will open the On Fri, 22 Jan 2016 10:36 StephJan [email protected] wrote:
|
I'll try tis then, thanks for the tip :) For info, what will the notification consist of, since I don't provide any notification section to fill it properly ? |
depends on the keys, it is just the same stuff you would put into the notification property |
Never thought about trying that :) I'll try that, thanks again for the heads up |
@StephJan if you want the notification called when the app is in the background, see Background Notifications in the docs. |
@macdonst I actually followed suggestion from AdriVanHoudt, works like a charm:
|
@StephJan kk, as long as you are happy |
@StephJan What happens when you receive 3 seperate notifications when your app is in background? |
@nuclearsagar you should only recieve the notification that is being clicked on |
@AdriVanHoudt Does it mean that I am loosing other 2 notifications? I am struggling at this issue since last 10 days. |
The other notifications stay in the schade(where you click them) how to get all notifications is beyond my knowledge |
This thread has been automatically locked. |
The notification gets shown (because of default android handler I guess), and I can see the GCM log, but the plugin never catches it. It does work when I put the app back in the foreground so I guess some background registration is going wrong.
I have tried everything from any 1.4.x, 1.5.x version to downgrading my phonegap cli to 5.3.6 to going back in time with the code of my app.
Is there anything else I can try?
The text was updated successfully, but these errors were encountered: