iPhone 关闭时的 UILocalNotification
当设备关闭时安排 UILocalNotification 时会发生什么。
例如。我每天下午 3 点安排一次 UILocalNotification。但设备在下午 3:00 至 4:00 期间关闭。我猜想以下任何一个条件都成立。
- 设备重新启动后不会触发任何通知。
- 设备重新启动时(即下午 4:00)会触发通知,
我没有设备,无法在模拟器上测试它。
注意:关闭是指设备已关闭,而不是睡眠/待机模式
What happens when a UILocalNotofication is scheduled when a device is switched off.
Eg. I schedule a UILocalNotification at 3pm everyday. But the device is switched off from 3:00pm to 4:00pm. I guess any one of the following conditions will be true.
- No notification is fired after device is restarted.
- Notification is fired when the device is restarted i.e. at 4:00pm
I do not have a device and could not test it on a simulator.
Note: By switch off I mean that the device is turned off, and not sleep/stand by mode
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关闭和打开设备后将触发本地通知。
我编写了一个小型测试应用程序,用于验证此行为:
Local Notifications will be triggered after turning your device off and on.
I wrote a tiny test app, that verifies this behaviour:
当您关闭设备时,通知将不存在,因此当您重新打开设备时,如果不再次创建该通知,则不会发生任何事情。
因此,如果您将活动安排在下午 3 点,并且您的设备在下午 2:59 关闭,然后在下午 3:59 重新打开,则通知不会触发,因为必须重新创建它。
When you turn off your device, the notification becomes non-existant, so when you turn your device back on, nothing is going to happen without creating that notification again.
So if you schedule an event for 3PM and your device is turned off at 2:59PM, then back on at 3:59PM, the notification will not fire because it has to be recreated.