在iOS 8的背景永远运行的应用程序 [英] Running a app forever in the background in iOS 8

查看:96
本文介绍了在iOS 8的背景永远运行的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关于这一主题并没有什么这对我的作品的几个线程。我没有部署在App Store应用程序,这样我就可以在应用程序以保持其运行做黑客。什么办法可以让应用程序去,即使是后台运行?任何指针AP preciated。

There are several thread on this topic and nothing which works for me. I don't have to deploy the app in the app store, so I can do hacks in the app to keep it running. Any way I can keep the app going even when it is backgrounded? Any pointers appreciated.

推荐答案

我发现这个项目的github上解决这个问题: HTTPS ://github.com/voyage11/Location
显然,苹果将不批准这个技巧,但我想它会在你的情况下工作。

I found this github project solving this problem: https://github.com/voyage11/Location Obviously Apple wouldn't approve this hack, but I guess it would work in your case.

基本上,你要做的是:


  • 使用位置的背景模式在能力Info.plist中

  • 总是有后台任务运行,但不要让它运行超过一分钟。创建一个新的后台任务每分钟,停止旧的任务。

  • 除了previous任务滚动,还留着一个长期运行的后台任务。我不知道但如果真正需要。

  • 启动位置管理器每分钟和requestAlwaysAuthorization。

从引用code一些重要片段:

Some important snippets from the referenced code:

后台任务:

bgTaskId = [application beginBackgroundTaskWithExpirationHandler:^{
    [self.service debugLog:[NSString stringWithFormat:@"BG....background task %lu expired", (unsigned long)bgTaskId]];
}];

和启动位置管理器:

if(IS_OS_8_OR_LATER) {
    [_locationManager requestAlwaysAuthorization];
}
[_locationManager startUpdatingLocation];

这篇关于在iOS 8的背景永远运行的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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