feat: 포그라운드 상태에서 FCM data-only 수신 시 인앱 팝업 표시
This commit is contained in:
@@ -46,16 +46,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
|
||||
Messaging.messaging().appDidReceiveMessage(userInfo)
|
||||
// Print message ID.
|
||||
if let messageID = userInfo[gcmMessageIDKey] {
|
||||
DEBUG_LOG("Message ID: \(messageID)")
|
||||
if let type = userInfo["type"] as? String, type == "POINT_GRANTED" {
|
||||
NotificationCenter.default.post(name: .pointGranted, object: userInfo["message"])
|
||||
} else {
|
||||
Messaging.messaging().appDidReceiveMessage(userInfo)
|
||||
// Print message ID.
|
||||
if let messageID = userInfo[gcmMessageIDKey] {
|
||||
DEBUG_LOG("Message ID: \(messageID)")
|
||||
}
|
||||
|
||||
// Print full message.
|
||||
DEBUG_LOG("userInfo: \(userInfo)")
|
||||
|
||||
completionHandler(UIBackgroundFetchResult.newData)
|
||||
}
|
||||
|
||||
// Print full message.
|
||||
DEBUG_LOG("userInfo: \(userInfo)")
|
||||
|
||||
completionHandler(UIBackgroundFetchResult.newData)
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
||||
@@ -283,5 +287,6 @@ extension AppDelegate : UNUserNotificationCenterDelegate {
|
||||
}
|
||||
|
||||
extension Notification.Name {
|
||||
static let pointGranted = Notification.Name("POINT_GRANTED")
|
||||
static let didReceiveHomeTab = Notification.Name("didReceiveHomeTab")
|
||||
}
|
||||
|
Reference in New Issue
Block a user