好吧,我沒有得到有關這個問題的答案。 :(在後臺執行間隔輸出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背景模式下執行代碼時?您在背景模式下接收輸出? ..... –