|
|
|
@ -25,6 +25,9 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
|
|
|
|
|
self.contentHandler = contentHandler
|
|
|
|
|
self.request = request
|
|
|
|
|
|
|
|
|
|
// Resume database
|
|
|
|
|
NotificationCenter.default.post(name: Database.resumeNotification, object: self)
|
|
|
|
|
|
|
|
|
|
guard let notificationContent = request.content.mutableCopy() as? UNMutableNotificationContent else {
|
|
|
|
|
return self.completeSilenty()
|
|
|
|
|
}
|
|
|
|
@ -237,6 +240,10 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
|
|
|
|
|
|
|
|
|
|
private func completeSilenty() {
|
|
|
|
|
SNLog("Complete silenty")
|
|
|
|
|
|
|
|
|
|
// Suspend the database
|
|
|
|
|
NotificationCenter.default.post(name: Database.suspendNotification, object: self)
|
|
|
|
|
|
|
|
|
|
self.contentHandler!(.init())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -298,11 +305,10 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
|
|
|
|
|
SNLog("Add remote notification request")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private func handleSuccess(for content: UNMutableNotificationContent) {
|
|
|
|
|
contentHandler!(content)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private func handleFailure(for content: UNMutableNotificationContent) {
|
|
|
|
|
// Suspend the database
|
|
|
|
|
NotificationCenter.default.post(name: Database.suspendNotification, object: self)
|
|
|
|
|
|
|
|
|
|
content.body = "You've got a new message"
|
|
|
|
|
content.title = "Session"
|
|
|
|
|
let userInfo: [String:Any] = [ NotificationServiceExtension.isFromRemoteKey : true ]
|
|
|
|
|