fix: data message 푸시

- userNotificationCenter willPresent withCompletionHandler 메서드에 POINT_GRANTED메시지를 캐시할 수 있도록 코드 추가
This commit is contained in:
Yu Sung
2025-05-20 17:34:34 +09:00
parent 65373ae418
commit a92e04044e

View File

@@ -46,8 +46,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
} }
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { 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" { if let type = userInfo["type"] as? String, type == "POINT_GRANTED" {
DispatchQueue.main.async {
NotificationCenter.default.post(name: .pointGranted, object: userInfo["message"]) NotificationCenter.default.post(name: .pointGranted, object: userInfo["message"])
}
} else { } else {
Messaging.messaging().appDidReceiveMessage(userInfo) Messaging.messaging().appDidReceiveMessage(userInfo)
// Print message ID. // Print message ID.
@@ -55,9 +60,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
DEBUG_LOG("Message ID: \(messageID)") DEBUG_LOG("Message ID: \(messageID)")
} }
// Print full message.
DEBUG_LOG("userInfo: \(userInfo)")
completionHandler(UIBackgroundFetchResult.newData) completionHandler(UIBackgroundFetchResult.newData)
} }
} }
@@ -242,6 +244,12 @@ extension AppDelegate : UNUserNotificationCenterDelegate {
// Print full message. // Print full message.
DEBUG_LOG("userInfo: \(userInfo)") 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 // Change this to your preferred presentation option
completionHandler([.banner, .badge, .sound]) completionHandler([.banner, .badge, .sound])
} }