Presents alert when we fail to extend background refresh time

This commit is contained in:
Riley Testut
2019-06-25 13:35:09 -07:00
parent d129ae8e1f
commit 3537dd11b0

View File

@@ -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.