From c19b53767bbfbc4a559502e6f63b52ba1544ec0a Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Tue, 22 Apr 2025 18:44:05 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=8F=AC=EA=B7=B8=EB=9D=BC=EC=9A=B4?= =?UTF-8?q?=EB=93=9C=20=EC=83=81=ED=83=9C=EC=97=90=EC=84=9C=20FCM=20data-o?= =?UTF-8?q?nly=20=EC=88=98=EC=8B=A0=20=EC=8B=9C=20=EC=9D=B8=EC=95=B1=20?= =?UTF-8?q?=ED=8C=9D=EC=97=85=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SodaLive/Sources/App/AppDelegate.swift | 23 ++++++++++++++--------- SodaLive/Sources/ContentView.swift | 22 +++++++++++++++++++++- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/SodaLive/Sources/App/AppDelegate.swift b/SodaLive/Sources/App/AppDelegate.swift index 306664d..dffcb23 100644 --- a/SodaLive/Sources/App/AppDelegate.swift +++ b/SodaLive/Sources/App/AppDelegate.swift @@ -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") } diff --git a/SodaLive/Sources/ContentView.swift b/SodaLive/Sources/ContentView.swift index e05aed3..538f6e0 100644 --- a/SodaLive/Sources/ContentView.swift +++ b/SodaLive/Sources/ContentView.swift @@ -10,6 +10,9 @@ import SwiftUI struct ContentView: View { @StateObject private var appState = AppState.shared + @State private var isShowDialog = false + @State private var message = "" + var body: some View { ZStack { Color.black.ignoresSafeArea() @@ -199,7 +202,7 @@ struct ContentView: View { case .tempCanPayment(let orderType, let contentId, let title, let can): CanPaymentTempView(orderType: orderType, contentId: contentId, title: title, can: can) - + case .blockList: BlockMemberListView() @@ -243,6 +246,23 @@ struct ContentView: View { EmptyView() .frame(width: 0, height: 0, alignment: .topLeading) } + + if isShowDialog { + SodaDialog( + title: "포인트 지급", + desc: message, + confirmButtonTitle: "확인" + ) { + isShowDialog = false + message = "" + } + } + } + .onReceive(NotificationCenter.default.publisher(for: .pointGranted)) { + if let msg = $0.object as? String { + self.message = msg + self.isShowDialog = true + } } } }