如何在ios7的后台运行进程

编程入门 行业动态 更新时间:2024-10-10 08:26:12
本文介绍了如何在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分钟, 。

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.

推荐答案

这是因为completionHandler是在后面调用的。 5分钟。您无法在iOS中无限期运行后台进程,直到您使用 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.

例如,如果您使用VoiPBackgroundMode,您的应用程序应提供VoiP服务,否则将被拒绝

For example if you use "VoiP" BackgroundMode you application should provide "VoiP services" otherwise it will be rejected

更多推荐

如何在ios7的后台运行进程

本文发布于:2023-11-16 02:16:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1600096.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:后台   进程   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!