how to run process in background in ios7(ios7如何在后台运行进程)
问题描述
我想在前台和后台连续运行我的进程.我已经实现了以下代码
I want to run my process in fore ground and background continuously.I've implemented the following code
self.updateTimer = [NSTimer scheduledTimerWithTimeInterval:10.0
target:self
selector:@selector(repeatedMethod)
userInfo:nil
repeats:YES];
self.backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
NSLog(@"Background handler called. Not running background tasks anymore.");
[[UIApplication sharedApplication] endBackgroundTask:self.backgroundTask];
self.backgroundTask = UIBackgroundTaskInvalid;
}];
在前台很好,但在后台进程只运行了 5 分钟,并且运行时间不超过 5 分钟.但我希望它即使在后台也能连续运行.请帮助.
In foreground it is fine but in background process is running for just 5 mins and not running more than that.But I want it to run continuously even in background also.please help.
推荐答案
发生这种情况,因为完成处理程序在 5 分钟后被调用.在使用 UIBackgroundModes 这也是依赖的如果您在应用程序中使用它,则必须提供 BackgroundMode 的功能,否则苹果将拒绝它.
Thats happening, because the completionHandler is called after 5 mins.You cannot run a background process for indefinite period in iOS until you use one of the UIBackgroundModes and that too is dependent upon you must provide a functionality of BackgroundMode if you use it in your application otherwise apple will reject it.
例如,如果您使用VoiP"BackgroundMode,您的应用程序应提供VoiP 服务",否则将被拒绝
For example if you use "VoiP" BackgroundMode you application should provide "VoiP services" otherwise it will be rejected
这篇关于ios7如何在后台运行进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ios7如何在后台运行进程
基础教程推荐
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01