override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
self.bestAttemptContent = request.content
if let content = bestAttemptContent,
let topic = content.userInfo["topic"] as? String,
let ciphertext = content.userInfo["message"] as? String,
let tag = content.userInfo["tag"] as? UInt {
if WalletKitDecryptionService.canHandle(tag: tag) {
let mutableContent = handleWalletKitNotification(content: content, topic: topic, tag: tag, ciphertext: ciphertext)
contentHandler(mutableContent)
} else if NotifyDecryptionService.canHandle(tag: tag) {
let mutableContent = handleNotifyNotification(content: content, topic: topic, ciphertext: ciphertext)
contentHandler(mutableContent)
} else {
let mutableContent = content.mutableCopy() as! UNMutableNotificationContent
mutableContent.title = "Error: unknown message tag"
}
}
}