Notifications when app is closed


#1

When my app is closed, or runs in the background, and I open a notification, it is not handled. In fact, it doesn’t even call the handler. (push.on('notification')) however, when I am inside the app, it works.

Normally, I initialise push handlers after the user is logged in (he doesn’t have to manually, server just verifies a token), but even if I set it exactly on platform.ready it still does

Any advice?


#2

Which platform do you encounter this problem?
Are you sure that this is possible on that platform without additional work?


#3

Android. On iOS it works perfectly as intended, but on Android, notifications from outside doesn’t work… (same code, pretty sure android should also work from outside)


#4

I am not any more, that’s why I am asking :slight_smile:

See here for example: http://stackoverflow.com/questions/37711082/how-to-handle-notification-when-app-in-background-in-firebase This is specific to FCM, but I assume the same was valid for GCM that you (and your push service) are probably still using. Looking into it, the relevant part for GCM was if the data was sent in “notification” or “data”: https://github.com/phonegap/phonegap-plugin-push/issues/387#issuecomment-160741666

Interesting that this isn’t better documented and known. (Or I’m just an idiot… possible)


#5

That’s very interesting!
I am using FCM (using node fcm-push) and am sending my payload in data, and in notification I just send: title, tag, color, body, sound (not relevant app data, just notification thing)

Is that not good?
Not much to read on the subject…


#6

As I read it you should decide if you want to use notification or data - and leave the other one out of the message to make sure it works as expected.


#7

Solved! https://github.com/phonegap/phonegap-plugin-push/issues/1609#issuecomment-282394756
Cheers


#8

what was the fix? As i read your comments in git it was something with the payload?

cheers