내 앱이 백그라운드를 10 분 이상 실행하지 않는 문제에 직면했습니다. 즉각적으로 알림을 가져 오는 백그라운드 작업을 구현했습니다.내 iPhone 앱 백그라운드 프로세스가 10 분 후에 종료됩니다.
내 응용 프로그램의 백그라운드 작업은 10 분 후, 나는 이미 this 및 this의 솔루션을 주심을 한 중지하지만, 사전에
-(void)methodBGTask :(UIApplication *)application{
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]) { //Check if our iOS version supports multitasking I.E iOS 4
if ([[UIDevice currentDevice] isMultitaskingSupported]) { //Check if device supports mulitasking
//create new uiBackgroundTask
__block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
//and create new timer with async call:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//run function methodRunAfterBackground
NSTimer* t = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(methodGetNotificatioin) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:t forMode:NSDefaultRunLoopMode];
[[NSRunLoop currentRunLoop] run];
});
}
}
}
-(void)methodGetNotificatioin{
//retrieve notifications from service
}
감사를 다음과 같이
내 코드가 도움이 같지 않습니다
이것은 예상되는 동작이며 10 분 제한이 있으며 문서를 읽습니다! –
내가 downvoted하지 않은,하지만 그것은 꽤 명확하게 문서에서 배경 작업 시간 제한 및 또한 이러한 유형의 작업을 위해 그들을 사용하지 않도록 경고 명시된 때문인 것 같아요. –
나는 당신이 어떤 연구도하지 않고 질문을했기 때문에 나는 다운 받았다. 이것은 사과에서 매우 명확하게 설명되어 있습니다. (직접 읽었습니다.) –