所以我按照本教程https://www.ioscreator.com/tutorials/background-fetch-ios-tutorial进行了背景抓取,效果很好,但是我尝试更改应用程序图标,而代码根本没有被调用。
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
//1
if let viewController = window?.rootViewController as? ViewController {
viewController.updateTime()//gets called and preformed perfectly in background
UIApplication.shared.setAlternateIconName("blue", completionHandler: nil)//doesn't get called at all but as a button press function in ViewController it worked with me perfectly
}
}