func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
print(UIApplicationBackgroundFetchIntervalMinimum)
UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)
return true
}
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
completionHandler(.newData)
}
This is my code and when I Debug in XCode > Simulate background fetch my app crash without reason. I activated in Capabilities>Background modes>Background fetch... any ideas?
It crash only on iPhone in simulator I don't have problems.
答案 0 :(得分:3)
根据您的上述说明,我在我的项目中尝试了它,但它工作正常,performFetchWithCompletionHandler
也在后台工作。
首先我尝试不添加此属性,但未调用performFetchWithCompletionHandler。所以,尝试在info.plist文件中添加它
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
</array>
它将解决我的问题