-
Notifications
You must be signed in to change notification settings - Fork 1.9k
plugin doesn't work in background or when app not running on kitkat 4.4.2 #754
Comments
Add a title attribute to your payload, rest should work. |
Thanks ansaritameem, but the problem turned out to be it was just a little bit too late in the evening.... As soon as I looked at it next day, and looked at the docs again, I realised that I was missing the crucial "content-available":"1" data in the payload (See https://github.com/phonegap/phonegap-plugin push/blob/master/docs/PAYLOAD.md#background-notifications - "Background notifications" section) So all I needed in the payload was { And it started working. At this point foreground, background and alerts when the app wasn't running were all successfully delivered. To be clear, I didn't need the "Title" - but a good suggestion. Thanks to Simon for a very useful plugin. |
@peterturquoise,Thanks for sharing your feedback... I should have studied this better. I found that setting the title was more than sufficient for Android to deliver notifications on foreground & background. I am using Azure Notification Hubs and I am now wondering if it pads up anything to the payload or not. What are you using to push the notification to the devices? Do you find any difference between setting the title w/o the content-available attribute and vice versa or both? |
@ansaritameem & @peterturquoise: If you set the title or message/body parameter in the data object of your push payload you should get a notification in the notification shade area of your Android device if the app is in the background or stopped. If you want to see the notification in the foreground as well then you set the The If you want the |
Even with |
@samuelcastro what does you payload look like? |
@macdonst see below:
|
@samuelcastro would like to see you logcat when reproducing the bug, |
@macdonst See below:
|
This thread has been automatically locked. |
Expected behabiour: I expect that a notification should be shown when the app using the plugin is not running and when it is running in the background
Actual behaviour: I can send a push message when the app is in the foreground and it works OK, but when the app is not running or is in the background, the push message is not shown.
The push message is simple and has the format {"data":{"message":"some message"}}
Any ideas ? I am using plugin version 1.6.1. The previous plugin version I used was 1.5.3 and I had the same issue with notifications not appearing in background or when the app wan't running but working fine with the app in foreground.
All works great in iOS. The app is built with cordova (via ionic) 6.0.0.
Reproduce Scenario (including but not limited to): Build an app in cordova 6.000 with the plugin, run the app on kitkat 4.4.2 and send it a push notification. The notification will display when the app is running in the foreground, but will not display of the app is in the background or if the app is not running.
Steps to Reproduce
Platform and Version (eg. Android 5.0 or iOS 9.2.1): Android 4.4.32
(Android) What device vendor (e.g. Samsung, HTC, Sony...): Alcatel Pixi
Cordova CLI version and cordova platform version
Plugin version
Sample Push Data Payload: {"data":{"message":"dd"}}
Sample Code that illustrates the problem
Logs taken while reproducing problem: I can take logs if that would help - what logs do you need and how can I get them?
The text was updated successfully, but these errors were encountered: