From a92e04044e2796797f7257877011a35cda632be8 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Tue, 20 May 2025 17:34:34 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20data=20message=20=ED=91=B8=EC=8B=9C=20-?= =?UTF-8?q?=20userNotificationCenter=20willPresent=20withCompletionHandler?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=EC=97=90=20POINT=5FGRANTED?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=EB=A5=BC=20=EC=BA=90=EC=8B=9C?= =?UTF-8?q?=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SodaLive/Sources/App/AppDelegate.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/SodaLive/Sources/App/AppDelegate.swift b/SodaLive/Sources/App/AppDelegate.swift index dffcb23..892f008 100644 --- a/SodaLive/Sources/App/AppDelegate.swift +++ b/SodaLive/Sources/App/AppDelegate.swift @@ -46,8 +46,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { + // Print full message. + DEBUG_LOG("didReceiveRemoteNotification userInfo: \(userInfo)") + if let type = userInfo["type"] as? String, type == "POINT_GRANTED" { + DispatchQueue.main.async { NotificationCenter.default.post(name: .pointGranted, object: userInfo["message"]) + } } else { Messaging.messaging().appDidReceiveMessage(userInfo) // Print message ID. @@ -55,9 +60,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { DEBUG_LOG("Message ID: \(messageID)") } - // Print full message. - DEBUG_LOG("userInfo: \(userInfo)") - completionHandler(UIBackgroundFetchResult.newData) } } @@ -242,6 +244,12 @@ extension AppDelegate : UNUserNotificationCenterDelegate { // Print full message. DEBUG_LOG("userInfo: \(userInfo)") + if let type = userInfo["type"] as? String, type == "POINT_GRANTED" { + DispatchQueue.main.async { + NotificationCenter.default.post(name: .pointGranted, object: userInfo["message"]) + } + } + // Change this to your preferred presentation option completionHandler([.banner, .badge, .sound]) }