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

Commit 2b4748c

Browse files
chriscantmacdonst
authored andcommitted
clearAll notifications on Android if count zero when in background (#2521)
1 parent a1e0e46 commit 2b4748c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

docs/PAYLOAD.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ The following flowchart attempts to give you a picture of what happens when a pu
6060
- If the app is running in the background the push plugin then checks to see if `content-available` exists in the push data.
6161
- If `content-available` is set to `1`, then the plugin calls all of your `notification` event handlers.
6262

63+
> Note: if `count` is given as `0` then all notifications are first cleared: always on Android, and if the `count` has gone down on iOS
64+
6365
## User clicks on notification in notification center
6466

6567
- The app starts.

src/android/com/adobe/phonegap/push/FCMService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ private void showNotificationIfPossible(Context context, Bundle extras) {
329329
Log.d(LOG_TAG, "count =[" + badgeCount + "]");
330330
PushPlugin.setApplicationIconBadgeNumber(context, badgeCount);
331331
}
332+
if (badgeCount == 0) {
333+
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
334+
mNotificationManager.cancelAll();
335+
}
332336

333337
Log.d(LOG_TAG, "message =[" + message + "]");
334338
Log.d(LOG_TAG, "title =[" + title + "]");

0 commit comments

Comments
 (0)