phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

[Android] on('notification') 'coldstart' value is acting wacky and not as documented (works only on iOS) #2939

Open livesemantics opened 3 years ago

livesemantics commented 3 years ago

Expected Behaviour

According to the documentation: data.additionalData.coldstart: Will be true if the application is started by clicking on the push notification, false if the app is already started.

Actual Behaviour

On iOS, coldstart behaves as expected. On Adnroid, when app in background and receiving notifications from FCM with only data section that includes "title", "message" and some app specific data.

  1. If payload also contains "content-available": "1" then on('notification') is always fired with "coldstart":true, "foreground":false when app receives notification in the background, and also when user clicks on the notification.

  2. If payload contains "content-available": "0" then on('notification') is fired only when user clicks on the notification (as expected) but with "coldstart":false, "foreground":false.

Platform and Version

Android Version: 10 Device: Samsung Galaxy A series Cordova CLI: 9.0.3 Cordova android version: 8.1.0 phonegap-plugin-push: 2.3.0 (Sending push from AWS-SNS using FCM for Android and APNS for iOS)

Sample Push Data Payload

{ "data": { "title": "my title", "message": "my message", "notId": 206891, "collapse_key": "2231900", "time_to_live": 86400, "content-available": "1", "lastUpdate": "2020-07-28T08:53:14Z", "data-key-1": 2231900, "data-key-2": [... array of numbers ...] } }