From 35a2c389b3f01247786dc4345ecc51729e9a05e2 Mon Sep 17 00:00:00 2001 From: QSD_faris Date: Fri, 9 Feb 2024 09:08:02 +0100 Subject: [PATCH] check if push notification is sent by Deskpro --- Sources/Deskpro.swift | 11 +++++++---- Sources/Messenger.swift | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Sources/Deskpro.swift b/Sources/Deskpro.swift index aa37133..6f60773 100644 --- a/Sources/Deskpro.swift +++ b/Sources/Deskpro.swift @@ -96,14 +96,17 @@ public final class DeskPro: Messenger { /// /// This method examines the provided push notification data to determine whether it is intended for the DeskPro SDK. /// - /// - Parameter pushNotification: The push notification data to be analyzed. + /// - Parameter data: The push notification data to be analyzed. /// /// - Returns: `true` if the push notification is related to DeskPro; `false` otherwise. /// /// - Tag: isDeskProPushNotification - public final func isDeskProPushNotification(pushNotification: PushNotificationData) -> Bool { - // TODO: Not yet implemented - return true + public final func isDeskProPushNotification(data: [AnyHashable: Any]) -> Bool { + if let issuer = data["issuer"] as? String { + return issuer == "deskpro-messenger" + } else { + return false + } } /// Handles the incoming push notification data if it is related to DeskPro. diff --git a/Sources/Messenger.swift b/Sources/Messenger.swift index 3e42692..bb5f955 100644 --- a/Sources/Messenger.swift +++ b/Sources/Messenger.swift @@ -52,12 +52,12 @@ protocol Messenger { /// /// This method examines the provided push notification data to determine whether it is intended for the DeskPro SDK. /// - /// - Parameter pushNotification: The push notification data to be analyzed. + /// - Parameter data: The push notification data to be analyzed. /// /// - Returns: `true` if the push notification is related to DeskPro; `false` otherwise. /// /// - Tag: isDeskProPushNotification - func isDeskProPushNotification(pushNotification: PushNotificationData) -> Bool + func isDeskProPushNotification(data: [AnyHashable: Any]) -> Bool /// Handles the incoming push notification data if it is related to DeskPro. ///