简体   繁体   English

如何在设备时区更改时调整iOS本地通知

[英]How to adjust the iOS Local Notifications on device timezone change

We have developed an iOS application which allows users to set some alarms based on the time given. 我们开发了一个iOS应用程序,允许用户根据给定的时间设置一些警报。 These set alarms are displayed in my "Alarm scheduler" screen of my application. 这些设置的警报显示在我的应用程序的“警报调度程序”屏幕中。 The local notification will trigger this alarm when set time is reached. 到达设置的时间时,本地通知将触发此警报。

Now if user changes his timezone say from EDT to PDT, then the "Alarm scheduler" screen is showing the alarm time properly, but my local notification is not getting triggered. 现在,如果用户将其时区从EDT更改为PDT,则“ Alarm Scheduler”屏幕将正确显示警报时间,但不会触发我的本地通知。

For example suppose its 8:55 AM EDT and user has set the alarm to trigger at 9:00 AM EDT. 例如,假设其美国东部时间上午8:55,并且用户已将警报设置为在美国东部时间上午9:00触发。 Now my "Alarm scheduler" screen will show the alarm time as "9:00 AM", now if user changes the timezone to PDT, then the "Alarm scheduler" page will display the alarm time as "6:00 AM" which is correct and users phone will show the time as "5:55 AM". 现在,我的“警报调度程序”屏幕将警报时间显示为“ 9:00 AM”,如果用户将时区更改为PDT,则“警报调度程序”页面将警报时间显示为“ 6:00 AM”正确,用户电话将显示时间为“ 5:55 AM”。 However after 5 mins when "6:00 AM PDT" is reached the local notification is not getting triggered. 但是,在到达“ 6:00 AM PDT”的5分钟后,不会触发本地通知。

Can some one advice how to achieve this? 有人可以建议如何实现这一目标吗?

Did you sent any timezone when scheduling local notification? 安排本地通知时,您是否发送了任何时区?

When you sent time zone to notification all hard work is done for you by OS. 当您将时区发送给通知时,操作系统将为您完成所有艰苦的工作。

This might help you.. 这可能对您有帮助。

On changing system's timezone, 在更改系统的时区时,

UIApplicationDelegate's --> applicationSignificantTimeChange: UIApplicationDelegate的-> applicationSignificantTimeChange:

method gets called. 方法被调用。 You can manage your stuff there. 您可以在那里管理您的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM