Telerik-Verified-Plugins / LocalNotification

Apache License 2.0
21 stars 27 forks source link

Notification persistence #7

Closed fer8a closed 8 years ago

fer8a commented 9 years ago

Hello, I'm not sure if I'm missing something or this is supposed to work like this.

I've got this code to set two notifications.

var one = {
  id: Math.floor(Math.random()*101),
  title: 'title',
  text: 'text',
  badge : 1,
  at: new Date(new Date().getTime() + 1*90*60*1000),
  sound: 'alarm.mp3'
};

var two = {
  id: Math.floor(Math.random()*101),
  title: 'title',
  text: 'text',
  badge : 1,
  at: new Date(new Date().getTime() + 2*90*60*1000),
  sound: 'alarm.mp3'
};

window.plugin.notification.local.schedule(one);
window.plugin.notification.local.schedule(two);

They do play properly at the scheduled time, but after that they don't seem to be cleared? They persist still on the device. I restarted my phone and the same notifications appeared (I assume they get triggered because the schedule time is already in the past).

Is that intended? I only want them to play once and then disappear. Do I have to manually clear them after they are displayed?

EddyVerbruggen commented 9 years ago

Hi,

Just to be sure, can you add that random ID to the title as well, so you see it when the notification pops up? Perhaps it's your app scheduling new notifications every time? If not, I'll dive into it!

fer8a commented 9 years ago

Hello,

I did the test and the ID is indeed the same one.

EddyVerbruggen commented 9 years ago

Hi @fer8a I found a similar issue in the upstream repo we've forked. Have you seen it?

Do you have a bit of experience in Java so you can try the suggestions offered there? Otherwise you'll need to wait a little for me (or the upstream maintainer) to come up with a fix.

fer8a commented 9 years ago

Hello @EddyVerbruggen, Thanks for the reference I wasn't aware.

I already do a sort of workaround for this within my code, it's just that is far from elegant. I'll try suggestions over there until you or the upstream maintainer have the chance to fix it.

gitstc commented 8 years ago

Hi,

I am facing the same issue. I schedule a notification which appears fine, then I clear all notifications, but the same notification appears once I reboot the device. I event tried adding a time stamp to the notification's title to test if the same notification is being scheduled multiple times, and it did show the same time stamp even after rebooting the device. This means that the javascript code is not being called at all (this is important as I am using another plugin that gets called on the device startup).

I tried updating the native code with the suggestions that other people have posted in this thread: https://github.com/katzer/cordova-plugin-local-notifications/issues/571 but the updates did not seem to have any effect.

The only way to prevent the notifications from being rescheduled upon a reboot is to actually click on the notification the first time it is scheduled. This way, Android seems to be able to discard the notification and prevent it from being rescheduled.

By the way, I am not interested in having repeating notifications, I only need to schedule a notification once. I am saying this because in the previously mentioned thread, some people where trying to solve the issue for repeating notifications, which in my belief led them to update the functions that determined the notification's trigger time.

Can anybody suggest any workaround to this issue?

EddyVerbruggen commented 8 years ago

Hi, please update to 0.8.2dev4 which should fix this problem.

fer8a commented 8 years ago

Hi @EddyVerbruggen, I did update the plugin but now I'm unable to build my application. The error message below. issue

EddyVerbruggen commented 8 years ago

Version 0.8.2dev4 uses a gradle library reference which requires Cordova-Android 4 to build. Can you please try that in AppBuilder? In the meanwhile I'll see if 0.8.2dev5 can be made compatible with older releases as well.