I'm using IONIC
Framework and I'd like to set the badge of my application after I'm getting push notification.
Is there a way to do it when my application is closed?
it is for others who will run into the same problem. I believe your talking about making badge visible with the updated badge number you've received from server.
First thing to enable it in code in init method of Push like this
var push = PushNotification.init({
android: {
senderID: senderID,
icon: 'pushicon',
sound: "true",
iconColor: "#ED8B00"
},
browser: {
pushServiceURL: 'url'
},
ios: {
alert: "true",
**badge: "true",**
sound: "true"
},
windows: {}
});
In above code we've enabled badge {will be displayed in all iPhones and supported Android Phones as well}
Now from server side. add below part to your ios portion so will get the updatd count even your your app is in background.
This is for ios only, please add for android as per your requirements;
{
"aps": {
"alert": {
"title": "Received",
"body": "You have received a message from Kens"
},
"badge": 66
},
"received_id": "9223",
"pn_type": "RECEIVED"
}
This badge count will automatically get updated to apps badge count even app is in background.(but badge field should be in integer).
Thanks hope this helps and solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With