|
|
@ -122,17 +122,12 @@ extension DownloadNotificationManager { |
|
|
|
} |
|
|
|
|
|
|
|
private func sendNotification(with notification: DownloadNotification) { |
|
|
|
guard let name = notification.product["name"] as? String else { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
let notificationContent = UNMutableNotificationContent() |
|
|
|
notificationContent.title = NSLocalizedString("Update available", comment: "") |
|
|
|
notificationContent.body = String(format: NSLocalizedString("A new update for %@ is ready to be installed.", comment: ""), name) |
|
|
|
notificationContent.body = String(format: NSLocalizedString("A new update for %@ is ready to be installed.", comment: ""), notification.product.name) |
|
|
|
notificationContent.sound = UNNotificationSound.default |
|
|
|
notificationContent.categoryIdentifier = "p≡p" |
|
|
|
notificationContent.userInfo = notification.product |
|
|
|
|
|
|
|
notificationContent.userInfo = notification.product.productInfo |
|
|
|
|
|
|
|
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: Double.leastNonzeroMagnitude, |
|
|
|
repeats: false) |
|
|
@ -158,14 +153,18 @@ extension DownloadNotificationManager: UNUserNotificationCenterDelegate { |
|
|
|
|
|
|
|
switch response.actionIdentifier { |
|
|
|
case "installAction": |
|
|
|
if let product = response.notification.request.content.userInfo as? Product { |
|
|
|
delegate?.installSelected(with: product) |
|
|
|
guard let userInfo = response.notification.request.content.userInfo as? Dictionary<String, String>, |
|
|
|
let name = userInfo["name"], |
|
|
|
let filename = userInfo["filename"] |
|
|
|
else { |
|
|
|
break |
|
|
|
} |
|
|
|
let product = Product(name: name, filename: filename) |
|
|
|
delegate?.installSelected(with: product) |
|
|
|
case "notNowAction": |
|
|
|
delegate?.notNowSelected() |
|
|
|
default: |
|
|
|
break |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |