Hello,
I am currently migrating from the Ionic Push Service to One Signal in order to manage notifications in our app.
The thing is that we are interested in setting the badge number of the app icon to a certain number, which we could do with ionic push service but on One Signal this is only possible on IOS. I have been trying different approaches but i am currenlty a bit lost, the last one was this one:
setupPush(){
this.oneSignal.startInit('key1', 'key2');
this.oneSignal.handleNotificationReceived().subscribe(data => {
console.log('Recieved push notification: ', data);
//if(data.payload.additionalData){
this.badge.set(50);
// }
});
this.oneSignal.handleNotificationOpened().subscribe(data =>{
console.log('Opened a push notification: ', data);
let message = data.notification.payload.body;
let title = data.notification.payload.title;
let alert = this.alertCtrl.create({
title: title,
subTitle: message,
buttons:[
{
text: 'Close',
role: 'cancel'
}
]
})
alert.present();
});
this.oneSignal.endInit();
}
It is just a mock up to start working with notifications. In order to solve the One Signal Android problem with badges i tried to combine handleNotificationOpened() with badge.set(50) using the badge plugin.
The problem is that, this doesn’t work if the app is killed and it is not working on background.
Thanks in advance!!