根据手机中的警报注册时间更改时间时,通知警报未显示
Notification Alert is not showing when time is change according to alert register time in mobile
我注册了如下通知:
var date= new Date();
date.setHour(15);
date.setMinutes(10);
window.plugin.notification.local.add({
id: "p10", // A unique id of the notification
date: date, // This expects a date object
message: "Notification appear", // The message that is displayed
title: "hi", // The title of the message
json: String, // Data to be passed through the notification
autoCancel: true, // Setting this flag and the notification is automatically cancelled when the user clicks it
}, callback, scope);
这个工作正常,但如果我更改我的手机时间,那么这个通知不会显示?
如果我根据警报时间更改我的手机时间,那么我就不会收到警报。
为什么。?
由于您没有针对您的问题指定任何特定平台或插件,我自由地在 Android 和 Cordova Local-Notification Plugin. After extensive source reading I finally found (here on method add) that the implementation uses AlarmManager 上检查它以处理应用程序的唤醒以在以下时间发出通知它在背景上。
在查看AlarmManager 后,我很快发现如果手动更改时间,它并不能真正起作用。相反,您应该自己在应用程序上跟踪时间机会,然后在注意到此类修改时为 AlarmManager 重新创建警报。 Android 上要跟踪的事件是
Intent.ACTION_TIME_TICK
Intent.ACTION_TIMEZONE_CHANGED
Intent.ACTION_TIME_CHANGED
如Pankaj Kumar所述。
此外,用户 [user:Lucifer] 对以下问题有 this 赏金获奖回答:警报管理器是否在重启后仍然存在?。根据他的说法,简单的答案是否。有关更详细的说明,请参阅他的 post 那里。
我注册了如下通知:
var date= new Date();
date.setHour(15);
date.setMinutes(10);
window.plugin.notification.local.add({
id: "p10", // A unique id of the notification
date: date, // This expects a date object
message: "Notification appear", // The message that is displayed
title: "hi", // The title of the message
json: String, // Data to be passed through the notification
autoCancel: true, // Setting this flag and the notification is automatically cancelled when the user clicks it
}, callback, scope);
这个工作正常,但如果我更改我的手机时间,那么这个通知不会显示?
如果我根据警报时间更改我的手机时间,那么我就不会收到警报。 为什么。?
由于您没有针对您的问题指定任何特定平台或插件,我自由地在 Android 和 Cordova Local-Notification Plugin. After extensive source reading I finally found (here on method add) that the implementation uses AlarmManager 上检查它以处理应用程序的唤醒以在以下时间发出通知它在背景上。
在查看AlarmManager 后,我很快发现如果手动更改时间,它并不能真正起作用。相反,您应该自己在应用程序上跟踪时间机会,然后在注意到此类修改时为 AlarmManager 重新创建警报。 Android 上要跟踪的事件是
Intent.ACTION_TIME_TICK
Intent.ACTION_TIMEZONE_CHANGED
Intent.ACTION_TIME_CHANGED
如Pankaj Kumar所述。
此外,用户 [user:Lucifer] 对以下问题有 this 赏金获奖回答:警报管理器是否在重启后仍然存在?。根据他的说法,简单的答案是否。有关更详细的说明,请参阅他的 post 那里。