diff --git a/Sources/PushNotifications/PushNotificationHandler.swift b/Sources/PushNotifications/PushNotificationHandler.swift index b4f630b..ceb0401 100644 --- a/Sources/PushNotifications/PushNotificationHandler.swift +++ b/Sources/PushNotifications/PushNotificationHandler.swift @@ -12,6 +12,17 @@ import UserNotifications public class PushNotificationHandler { + public static func extractNotification(from payload: String, iv: String) async -> UNMutableNotificationContent? { + log.verbose("Notification received with payload: \(payload)") + + guard let notification = PushNotificationCipher.decrypt(payload: payload, iv: iv) else { + log.verbose("Notification could not be decrypted.") + return nil + } + + return await prepareNotification(notification) + } + public static func handle(payload: String, iv: String) { log.verbose("Notification received with payload: \(payload)") diff --git a/Sources/PushNotifications/Services/PushNotificationService/PushNotificationServiceImpl.swift b/Sources/PushNotifications/Services/PushNotificationService/PushNotificationServiceImpl.swift index fcfdad3..cec8fc4 100644 --- a/Sources/PushNotifications/Services/PushNotificationService/PushNotificationServiceImpl.swift +++ b/Sources/PushNotifications/Services/PushNotificationService/PushNotificationServiceImpl.swift @@ -60,6 +60,7 @@ class PushNotificationServiceImpl: PushNotificationService { var token: String var deviceType = "APNS" + var apiType = 1 var method: HTTPMethod { return .post