EddyVerbruggen / nativescript-local-notifications

:mailbox: NativeScript plugin to easily schedule local notifications
MIT License
162 stars 57 forks source link

Notification stops repeating after user clicks on notification on Android only. #180

Closed 7ammer closed 4 years ago

7ammer commented 4 years ago

It appears that when the Interval option is set it will repeat until the user clicks on the notification at which point it is canceled. This issue appears on android only.

I guess I can re-create the notification inside addOnMessageReceivedCallback but this is not ideal.

The code below shows how to replicate the notification getting canceled after clicking on the notification.

setup repeating notification:

LocalNotifications.schedule([{
    id: 1234,
    title: 'Reminder',
    body: "My text",
    interval: 'minute',
    at: selectedTime,
    forceShowWhenInForeground:true,
}])

showing the notification being canceled after 2 seconds without specifically canceling the notification:

LocalNotifications.addOnMessageReceivedCallback((notification) => {

    LocalNotifications.getScheduledIds().then((ids) => {
        // found id!
        console.log(ids , 'notification ids');
    });

    setTimeout(()=>{
        LocalNotifications.getScheduledIds().then((ids) => {
            // no ID's??? It must have been canceled? :(
            console.log(ids , 'notification ids');
        });
    }, 2000);
});
EddyVerbruggen commented 4 years ago

Can you try setting the ongoing property as well, when scheduling a notification? I think that's what interval should do internally but it doesn't at the moment.

7ammer commented 4 years ago

Hey @EddyVerbruggen,

Thanks for responding :)

Yep! Adding ongoing works and causes the schedule to be kept. However, (I'm sure you know this but) the notification isn't removable in the notifications list which isn't the best for my situation.

Cheers

EddyVerbruggen commented 4 years ago

Thanks, that's good to know as well.

I've now published 4.1.5 which should fix the problem without the need of adding ongoing.

7ammer commented 4 years ago

Super!

Many thanks @EddyVerbruggen !!!