好吧,我没有得到有关这个问题的答案。 :(在后台执行间隔输出IOS 7
Multipeer Connectivity audio streaming stop work on background
这个怎么样?
我试图运行在后台的代码。
- (void)applicationDidEnterBackground:(UIApplication *)application {
__block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSTimer *aTimer = [NSTimer timerWithTimeInterval:3
target:self
selector:@selector(showInformation)
userInfo:nil
repeats:YES];
[[NSRunLoop mainRunLoop]
addTimer:aTimer
forMode:NSDefaultRunLoopMode];
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
});
}
很明显,我IHAVE在同一范围内定义这个功能
- (void) showInformation {
NSLog(@"showInformation is called.");
}
但是,当我把应用程序放在后台,间隔我ssage,停止工作,当我回到前台继续工作........
这意味着不在背景上运行?
这可能吗?还是我试图做一些愚蠢的事情?
我真的很感谢一些帮助。
非常感谢。
好吧,我明白了,我读这一切后,并没有对我的作品,这不工作10分钟,这从来没有在后台运行,我已经启用VOIP,有更多的想法?谢谢 –
好男人我只是想节省你的时间;),VOIP适合我,但要小心你的应用程序应该是VOIP或它被拒绝,这个解决方案应该为你工作http://stackoverflow.com/a/4808049/1262634 – null
当您在启用VOIP背景模式下执行代码时?您在背景模式下接收输出? ..... –