최소 배경 가져 오기 간격을 지정할 수있는 iOS 백그라운드 가져 오기 기능을 사용할 수 있습니다. 그러나 코드를 연속적으로 호출하는 실제 간격은 iOS 프레임 워크에 의해 결정됩니다. swift-ios-refreshing-app-data-when-in-background
또 다른 옵션이 앱에 앱이 반응 할 수 5 분마다 (자동) 푸시 알림을 전송하는 서버를 설치하는 것입니다
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
let data: String? = nil
do {
//fetch some data
if let data = getSomeNewData() {
/* use the completionHandler to talk to the system and tell us if the app fetched new data, or if no data was available. */
completionHandler(.newData)
} else {
completionHandler(.noData)
}
} catch {
print(error)
completionHandler(.failed)
}
}
는 질문을 참조하십시오.
이것은 백그라운드에서 무엇을하고 싶은가에 달려 있습니다. iOS는 백그라운드에서 특정 작업 만 수행하도록 허용합니다. [장기 실행 작업 구현] (https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#// apple_ref/doc/uid/TP40007072-CH4-SW4) –
아마 당신의 접근 방식을 다시 생각할 필요가있을 것입니다. iOS는 일시 중지 된 응용 프로그램이 특정 시간 간격으로 실행되도록 예약하지 못하게합니다. 과제의 성격은 무엇입니까? 아마도 서버 푸시와 같은 다른 방법으로 트리거 할 수 있습니다. – Paulw11
읽어보기 : https://blog.newrelic.com/2016/01/13/ios9-background-execution/ –