-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android: All defined notifications run on device reboot #571
Comments
Same problem here, was coming to search and see if there were any comments about it. My app always just fires a single notification that gets updated with the same ID (it's a music app, so it's the currently playing song) - If I stop the music, then clear the notification, then reboot the phone.. the last song that was playing notification pops up again on reboot. Has to be an easy fix! Thanks |
1+ |
1 similar comment
1+ |
i solved this issue in my scenario....Go to Notification.java --> showNotification() method --> insert at the end of the method a call to "unpersist()".......Bye bye katzer |
hi, alessandrodamore , this solution cancel repeater notifications too.. is only applicable for one time notification |
exactly!! I talked about a solution that was fine in my scenario...I don't need that notifications be repeated......... The problem depends on how it is managed persistence options!! When you reboot your device/app AbstractRestoreReceiver is triggered and it try to recover all persisted options. Among these options you can see your old options because nobody has ever canceled. |
Well for me now making this replace on options.java, i can fix repeat for daily notification (i don't know about others notification) . if notification was in past, move it to tomorrow |
i think reeplacing AlarmManager.INTERVAL_DAY by interval can fix others repeats |
+1 |
@dansanti I don't quite follow what you mean by replacing the alarm manager, can you elaborate? |
HI,! i've change these solution, because some time cancel alert now, work fine (for repetitions alerts) :
after
then:
complete method:
|
This change definitely works. I recommend adopting this change. |
The Problem of the recurring notifications comes down to if (notification.isScheduled()) {
notification.schedule();
}
public boolean isScheduled () {
return isRepeating() || !wasInThePast();
} which refers to public boolean wasInThePast () {
return new Date().after(options.getTriggerDate());
} which uses public Date getTriggerDate() {
return new Date(getTriggerTime());
}
public long getTriggerTime() {
return Math.max(
System.currentTimeMillis(),
options.optLong("at", 0) * 1000
);
} Because of that, An easy solution would be to explicitly call public boolean wasInThePast () {
var triggerDate = options.getTriggerDate();
return new Date().after(triggerDate);
} It ensures that the call order of the two dates which will be compared is as it should be. Of couse there are other solutions which might be better to maintain in the long run: public long getTriggerTime() {
return Math.max(
System.currentTimeMillis(),
getOriginalTriggerTime()
);
}
public long getOriginalTriggerTime() {
return options.optLong("at", 0) * 1000;
}
public Date getOriginalTriggerDate() {
return new Date(getOriginalTriggerTime());
}
public boolean wasInThePast () {
return new Date().after(options.getOriginalTriggerDate());
} This solution makes it more explicit what is going on. In the end, the plugin would really benefit from an additional (optional) scheduling parameter |
@dansanti fix works. Just did as mentioned. Repeated notifications work correctly. Tested on android 4.3 . |
What is the status of this thread? Are the proposed changes submitted as a pull request to Sebastian @katzer? |
Hi! i testesd latest commit, in a clean installation and seems to works fine, bug fixed. |
I can confirm too that it is fixed. |
I can confirm too that is NOT fixed |
@AbstractH - care to elaborate? |
I only have my one device, but all the notifications I specified, in an extremely simple cut-down version of the kitchen-sink demo, are firing immediately after the device reboots. Even ones that I define but are orphaned because there is no JS code to fire them.
What could cause this?
(LG g3 Lollipop)
EDIT: this also is happening on the device emulators, as low as 2.3 Gingerbread, so I don't think it is an isolated issue.
The text was updated successfully, but these errors were encountered: