如何保持NSTimer活在iOS 7的背景? [英] How to keep NSTimer alive in Background on iOS 7?

查看:138
本文介绍了如何保持NSTimer活在iOS 7的背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了在后台运行NSTimer的应用程序。我使用位置管理器在后台运行NSTimer,

I have created Application which runs NSTimer in Background. I used the Location manager to run the NSTimer in background,

我在下面使用链接在后台运行NSTimer,

I used below link to run NSTimer in background,

如何在我的iOS应用程序中每n分钟更新一次背景位置?

这种方法在iOS 6中可以正常工作, iOS 7.我的应用程序崩溃一段时间后的应用程序在iOS 7的后台。

This approach works fine in iOS 6 but not works on iOS 7. My Application crashes after some time while Application in background on iOS 7.

请让我知道如果任何不同的方法在后台运行NSTimer

Please let me know if any different approach to run the NSTimer in background.

提前感谢。

推荐答案

,存在用于周期性数据提取的新模式。将 fetch 后台模式添加到您的应用程序,并在您的应用程序委托中传递一个间隔到 - [UIApplication setMinimumBackgroundFetchInterval:

In iOS7, there is a new mode for periodic data fetch. Add the fetch background mode to your app, and in your application delegate, pass an interval to - [UIApplication setMinimumBackgroundFetchInterval:. Your app's delegate will start receiving calls to application:performFetchWithCompletionHandler: once the app is in the background.

更多信息,您的应用程序代理将开始接收对应用程序:performFetchWithCompletionHandler:这里:
https://developer.apple.com/library/ios/documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:performFetchWithCompletionHandler

More information here: https://developer.apple.com/library/ios/documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:performFetchWithCompletionHandler:

这篇关于如何保持NSTimer活在iOS 7的背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆