plugins
plugins copied to clipboard
[@nativescript/local-notifications] Android - Message received callback fires multiple times
Android version: 11
nativescript CLI: 8.2.3 @nativescript/android: 8.2.2 @nativescript/local-notifications: 6.0.0
When I tap a local notification, the onReceived
function is called and all data is present.
LocalNotifications.addOnMessageReceivedCallback((message) => {
// message: { id: 6471, title: 'TITLE', body: `BODY`, payload: {...}, badge: 1, ...}
});
However, if I open to the app switcher and return to my app, the function is called again but the data object is almost empty. Every time I switch back to the app the callback fires.
{ event: 'default', foreground: true }
I have not tested yet on iOS or different Android versions.
I'm having the same issue. How can we fix this?
Seems to be coming from here, it is the default event. You can just ignore the call if the message.event is 'default' https://github.com/NativeScript/plugins/blob/184555c1af63a079693d3e12ec2cd9baf285a803/packages/local-notifications/native-src/android/app/src/main/java/com/telerik/localnotifications/LifecycleCallbacks.java#L98
Another place a default event could originate from https://github.com/NativeScript/plugins/blob/184555c1af63a079693d3e12ec2cd9baf285a803/packages/local-notifications/native-src/android/app/src/main/java/com/telerik/localnotifications/NotificationActionReceiver.java#L80