From 3537dd11b0545eaaa5c8e6c60cdfd092238cbc77 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Tue, 25 Jun 2019 13:35:09 -0700 Subject: [PATCH] Presents alert when we fail to extend background refresh time --- AltStore/AppDelegate.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/AltStore/AppDelegate.swift b/AltStore/AppDelegate.swift index 923abbf0..f4d660a9 100644 --- a/AltStore/AppDelegate.swift +++ b/AltStore/AppDelegate.swift @@ -94,7 +94,20 @@ extension AppDelegate BackgroundTaskManager.shared.performExtendedBackgroundTask { (taskResult, taskCompletionHandler) in if let error = taskResult.error { - print("Error starting extended background task.", error) + print("Error starting extended background task. Aborting.", error) + + let content = UNMutableNotificationContent() + content.title = NSLocalizedString("Failed to refresh apps.", comment: "") + content.body = taskResult.error?.localizedDescription ?? "" + + let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.01, repeats: false) + + let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger) + UNUserNotificationCenter.current().add(request) { (error) in + if let error = error { + print(error) + } + } } // Wait a few seconds so we have a chance to discover nearby AltServers.