phonegap / phonegap-plugin-push

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

Badge not working on android #2667

Open zechs424 opened 5 years ago

zechs424 commented 5 years ago

Expected Behaviour

The badge number is updated on app icon

Actual Behaviour

The badge number is remain the same. if I am using json object with only "data" object only, the badge number can update successfully. But for iOS, if I send json object with only "data" object, the notification will not show. So I send the json object with both "data" and "notification" object and found android's app icon badge cannot update.

Reproduce Scenario (including but not limited to)

send FCM notification using http method using json object with both "data" and "notification" object present

Steps to Reproduce

send fcm notification by http method using the following json object: { "to" : , "notification": { "title": "hih", "body" : "hey", "badge": 20 }, "data": { "title": "hihi", "message": "hey", "android_channel_id": , "badge": 20 } }

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Android 8.0 (API 26)

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Sony

Cordova CLI version and cordova platform version

cordova --version                                    # e.g. 6.0.0
8.0.0

cordova platform version android                     # e.g. 4.1.1
Installed platforms:
  android 7.1.4
  ios 4.5.5

Available platforms: browser ~5.0.1 osx ~4.0.1 windows ~5.0.0 www ^3.12.0

Plugin version

cordova plugin version | grep phonegap-plugin-push   # e.g. 1.5.3

phonegap-plugin-push 2.2.3 "PushPlugin"

Sample Push Data Payload

{ "to" : , "notification": { "title": "hih", "body" : "hey", "badge": 20 }, "data": { "title": "hihi", "message": "hey", "android_channel_id": , "badge": 20 } }

Sample Code that illustrates the problem

using http method of send fcm notfication from server side

Logs taken while reproducing problem

djsanj007 commented 5 years ago

same behaviour happening for me, Only problem with Android, Working fine on iOS My Android version is 7.0 on Samsung device

luidiva commented 5 years ago

var push = PushNotification.init({ ios: { badge: true, sound: true, alert: true } });

on some event (last parameter badge count): push.setApplicationIconBadgeNumber(() => ({}),() => ({}), 20);

SergTomcat commented 5 years ago

Same here. Working fine recieving badge number inside application, getting success in background, but badge doesn't appear on app icon (version 2.2.3)

N.B. getApplicationIconBadgeNumber returns correct count number. But it just doesn't show up visually.