在 iOS 中获取有关时区更改的通知

get notification on timezone change in iOS(在 iOS 中获取有关时区更改的通知)
本文介绍了在 iOS 中获取有关时区更改的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序可以在设备时区更改时收到任何通知吗?我想在我的应用程序处于前台时收到通知.NSTimezone 对我不起作用,因为我必须不断检查时区.

can my application get any notification when device timezone changed? I want to get a notification when my application is foreground. NSTimezone does not worked for me as i have to continuously check for timezone.

推荐答案

UIApplicationDelegate 有一个名为 applicationSignificantTimeChange: 的方法,当时间发生重大变化时会调用该方法.

UIApplicationDelegate has a method called applicationSignificantTimeChange: that gets called when there is a significant change in the time.

文档中列出的示例是:

重大时间变化的示例包括午夜的到来、运营商的时间更新以及夏令时的变化

Examples of significant time changes include the arrival of midnight, an update of the time by a carrier, and the change to daylight savings time

但我认为时区变化算作重大的时间变化.

But I would assume that timezone changes count as a significant time change.

文档还说,如果在您的应用处于后台时发生时间变化,您将在您转到前台时得到它

The docs also say that if the time change happens when your app is in the background you will get it when you go to the foreground

如果您的应用程序当前处于挂起状态,则此消息将排队等待您的应用程序返回到前台,此时它会被传递.

If your application is currently suspended, this message is queued until your application returns to the foreground, at which point it is delivered.

您还可以侦听要发布的 UIApplicationSignificantTimeChangeNotification 以在您应用的其他任何地方获取相同的信息.

You can also listen for UIApplicationSignificantTimeChangeNotification to be posted to get the same information anywhere else in your app.

这篇关于在 iOS 中获取有关时区更改的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)