Tag: 背景过程

应用程序未运行时iOS 7后台获取

我已经写了一个简单的应用程序,以testing和监控iOS7中的后台获取function的工作原理。 首先,我在Info.plist文件中设置了UIBackgroundMode选项。 然后; 我将下面的代码添加到AppDelegate.m中的application:didFinishLaunchingWithOptions:方法中: 最后,我已经实现了应用程序:(UIApplication *)应用程序performFetchWithCompletionHandler:方法请求。 每次点击Debug-> Simulate Background Fetchbutton,它都会更改应用程序的批号并按预期工作。 但是,当应用程序没有运行时,我从来没有能够使它工作(即使在后台模式下,只是没有运行)。 苹果说,当应用程序没有运行,操作系统要分别执行下列方法: application:(UIApplication *)application didFinishLaunchingWithOptions: applicationDidEnterBackground:(UIApplication *)application application:(UIApplication *)application performFetchWithCompletionHandler: 所以我的问题是,有没有办法testing应用程序不运行时的后台获取? 我正在使用iOS 7.1在我的iPod 5 Gen上进行testing。

屏幕locking时HealthStore enableBackgroundDelivery

您好,我正在尝试安装启用后台交付的健康商店观察员。 我的问题是,屏幕locking时,它不会传递任何东西。 我已经简化了我的代码这个问题的重点:)我有我的plist HealthKit,我已经接受healthStoretypes的步数。 当应用程序打开并且屏幕未locking时,一切正常。 但是,当屏幕locking,我没有得到任何意见。 为了testing目的,频率被设置为立即。 我的代码如下 – (void)setupHealthStore{ if ([HKHealthStore isHealthDataAvailable]) { NSSet *readDataTypes = [self dataTypesToRead]; self.healthStore = [[HKHealthStore alloc]init]; [self.healthStore requestAuthorizationToShareTypes:nil readTypes:readDataTypes completion:^(BOOL success, NSError *error) { if (success) { HKQuantityType *quantityType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount]; [self.healthStore enableBackgroundDeliveryForType:quantityType frequency:HKUpdateFrequencyImmediate withCompletion:^(BOOL success, NSError *error) { if (success) { [self setupObserver]; } }]; } […]

在后台运行iOS App超过10分钟

我试图让我的应用程序在后台运行10分钟以上,根据这个和我的好以下。 (我想使用长时间的背景运行来跟踪一个位置,我的代码在这里只是使用计数器进行testing)任何人都可以帮忙指出问题所在? 实施长期运行的后台任务 对于需要更多执行时间来执行的任务,您必须请求特定的权限才能在后台运行它们,而不会被暂停。 在iOS中,只有特定的应用程序types才能在后台运行: 在后台播放可听内容的应用,例如音乐播放器应用 随时向用户通知其位置的应用,例如导航应用 支持网际协议语音(VoIP)的应用 需要下载和处理新内容的报亭应用程序从外部附件获得定期更新的应用程序 实现这些服务的应用程序必须声明它们支持的服务,并使用系统框架来实现这些服务的相关方面。 声明这些服务可以让系统知道你使用了哪些服务,但是在某些情况下,系统框架确实会阻止你的应用程序被挂起。 – (void)viewDidLoad { [super viewDidLoad]; counterTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ }]; count=0; theTimer=[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(countUp) userInfo:nil repeats:YES]; } – (void)countUp { { count++; NSString *currentCount; currentCount=[[NSString alloc] initWithFormat:@"%ld",count]; theCount.text=currentCount; [currentCount release]; } } 另一个问题:我可以让iOS应用程序永远在后台运行吗? —-编辑的代码添加位置,仍然不会运行超过10分钟,对我做错了什么帮助? – (void)viewDidLoad { [super viewDidLoad]; count=0; locationManager = […]