Cordova-plugin-firebase update badge when app in background

#1

Hello,

i want to update the badge number if a message is receive. but in in plugin cordova-plugin-firebase it is only possible, if the app is in foreground. how can i do that if the app is in background or closed?

i try the plugin cordova-plugin-fcm-with-dependecy-updated, but is not firing.

initializeApp() {
    this.platform.ready().then(() => {
      this.firebaseCloudMsg.onNotification().subscribe(data => {
        console.log('DATA: ', data);
        if(data.wasTapped){
          console.log("Received in background", data);
        } else {
          console.log("Received in foreground", data);
        };
      });

    });
  }

any solution for this problem?

#2

ok, i found a solution. i try to send the badge number direkt over the firebase console i an optional field. this is not working. but we use our own server to send push notifications from our system to https://fcm.googleapis.com/fcm/send.

what we need to send JSON in the correct format and then it works.

{
    "notification":{
	    "icon":"icon",
	    "body":"World!",
	    "title":"Hello",
	    "sound":"true",
	    "badge":"17"
        },
    "registration_ids":["YOUREDEVICEIDHERE"]
}