Open edyrkaj opened 5 years ago
On iOS?
yes @EddyVerbruggen. Thnx
I just confirmed with the embedded demo app, the badge is automatically cleared when either launched through the app icon or notification. Is that not working for you (with the demo)?
@EddyVerbruggen I have the same problem. Badge is cleared only when app is launched by tapping app icon. After tapping notification badge remains.
Platform: iOS TNS version: 5.2.5 nativescript-local-notifications version: 3.1.2
My code:
` public emit(notification: INotification): void {
const id = Math.floor(Math.random() * 1000000);
LocalNotifications.schedule([{
id: id,
title: notification.title,
body: notification.body,
color: new Color('#0050a0'),
forceShowWhenInForeground: true,
badge: notification.badge,
sound: notification.sound ? 'default' : null
}]).then(() => {
console.log('notification scheduling success!');
}).catch(() => {
console.log('notification scheduling error!');
});
LocalNotifications.addOnMessageReceivedCallback((data: ReceivedNotification) => {
if (!this.routerExtensions.router.isActive(notification.redirectPath, true)) {
this.routerExtensions.navigate([notification.redirectPath], {
transition: {
name: 'fade'
}
});
LocalNotifications.cancel(data.id);
} else {
LocalNotifications.cancel(data.id);
}
}).then(() => {
console.log('notification received callback success!');
}).catch(() => {
console.log('notification received callback error!');
});
LocalNotifications.addOnMessageClearedCallback((data: ReceivedNotification) => {
LocalNotifications.cancel(data.id);
}).then(() => {
console.log('notification cleared callback success!');
}).catch(() => {
console.log('notification cleared callback error!');
});
}`
Hi, I have the same issue. I tap the app icon but the badge remains. And if I tap again second time and launch the app, then the badge disappears. Is there a solution for this. Appreciate any help
Moreover, when I tap the icon when there is not any notification, the badge appears . In order to clear it, user has to launch and close the app. I have this issue on IOS. I haven't tested in Android. Thx in advance.
I just added UIApplication.sharedApplication.applicationIconBadgeNumber = 0;
just incase anyone else has a problem.
Exists any possibility to clear badge number after clicking the notification?