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

When app is in background, clicking on Android notification in shade opens app but does not trigger the on('notification') event handler #326

Closed
stinju opened this issue Nov 11, 2015 · 4 comments

Comments

@stinju
Copy link

stinju commented Nov 11, 2015

On android, when the app is in the background, an incoming notification will trigger GCMIntentService.onMessageReceived, buzz the app, open the app (when clicked in shade), but will not trigger my listener (via push.on('notification') in js) to the "notification" event.

As @macdonst mentioned here,

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.

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.

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.

@stinju
Copy link
Author

stinju commented Nov 11, 2015

Also note that downgrading this plugin to 1.3.0 resolves my issue. Thanks!

@stinju
Copy link
Author

stinju commented Nov 12, 2015

@macdonst huge apologies here. I removed and re-added the plugin in my project, and the scenario works correctly. I have a small patch with a new hasPermission call that I put in to get notification settings, and that has somehow affected the scenario described above. Closing this. Sorry for the wasted cpu cycles!

@stinju stinju closed this as completed Nov 12, 2015
@macdonst
Copy link
Member

@stinju ok, np. Glad it got resolved.

@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked.

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

No branches or pull requests

2 participants