만료 처리기가 호출되면 앱을 로그 아웃하려고합니다. 이것은 시간의 일부이지만, endBackgroundTask를 호출하여 백그라운드 작업을 끝내더라도 프로세스를 어렵게 만드는 경우가 있습니다. 이 경우 로그 아웃 프로세스가 너무 오래 걸리고 iOS가 종료하는 것처럼 보입니다. 이것은 긴 작업이 아니어야하지만 추가 시간을 요청할 수있는 방법이 있습니까?iOS가 앱을 종료하기 전에 만료 처리기에서 정상적으로 작업을 끝내려면 어떻게해야합니까?
if ([app respondsToSelector:@selector(beginBackgroundTaskWithExpirationHandler:)]) {
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
// Synchronize the cleanup call on the main thread in case
// the task actually finishes at around the same time.
dispatch_async(dispatch_get_main_queue(), ^{
if (bgTask != UIBackgroundTaskInvalid) {
backgroundKilled = true;
[self logoutAll];
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}
});
}];
}
정말 멋진 다이어그램입니다. – tjg184