后台计时器IOS



在我的应用中,通过计时器,用户可以设置一个事件。我希望这个计时器即使应用在后台也能工作。我怎么能这么做?!

[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerFired) userInfo:nil repeats:YES];

如果你想在一段时间后触发一些动作,即使应用程序在后台,本地通知可以帮助你。

引用https://developer.apple.com/library/ios/DOCUMENTATION/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction.html

这里有教程http://www.appcoda.com/ios-programming-local-notification-tutorial/

注意:NSTimer会在应用程序进入后台时停止

最新更新