From 9840930491542ab7271c469cb2430e76883e43aa Mon Sep 17 00:00:00 2001 From: Minji Kim Date: Sat, 25 Feb 2023 11:10:55 +0900 Subject: [PATCH 1/3] [FEAT] Firebase Cloud Messaging --- PPAK_CVS.xcodeproj/project.pbxproj | 8 ++--- PPAK_CVS/Sources/AppDelegate.swift | 49 +++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/PPAK_CVS.xcodeproj/project.pbxproj b/PPAK_CVS.xcodeproj/project.pbxproj index 929d822d..517d7fd5 100644 --- a/PPAK_CVS.xcodeproj/project.pbxproj +++ b/PPAK_CVS.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 9CB55E9629A77FE800F6760A /* SettingTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CB55E9529A77FE700F6760A /* SettingTableViewCell.swift */; }; 9CCFA4FE28F4585E00963A95 /* EventType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CCFA4FD28F4585E00963A95 /* EventType.swift */; }; 9CDBFCD1296C331C00357474 /* SettingConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CDBFCD0296C331C00357474 /* SettingConfig.swift */; }; + A51AA36829A9A0BA00FEE77D /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = A51AA36729A9A0B900FEE77D /* GoogleService-Info.plist */; }; A52F113329A09D6E009FFE02 /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = A52F113229A09D6E009FFE02 /* FirebaseAnalytics */; }; A52F113529A09D6E009FFE02 /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = A52F113429A09D6E009FFE02 /* FirebaseCrashlytics */; }; A52F113729A09D6E009FFE02 /* FirebaseInAppMessaging-Beta in Frameworks */ = {isa = PBXBuildFile; productRef = A52F113629A09D6E009FFE02 /* FirebaseInAppMessaging-Beta */; }; @@ -114,7 +115,6 @@ E5B9965B28E2A16D00E39566 /* SortDropdownView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5B9965A28E2A16D00E39566 /* SortDropdownView.swift */; }; E5C9025228E2DB480086BDE9 /* HomeViewReactor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5C9025128E2DB480086BDE9 /* HomeViewReactor.swift */; }; E5CFF6F8297FD06C00E11D9A /* CVSStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5CFF6F7297FD06C00E11D9A /* CVSStorage.swift */; }; - E5D8019F29A70BC100A83CEE /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = E5D8019E29A70BC100A83CEE /* GoogleService-Info.plist */; }; E5F9CCA228EF10EA0084CD63 /* RxGesture in Frameworks */ = {isa = PBXBuildFile; productRef = E5F9CCA128EF10EA0084CD63 /* RxGesture */; }; /* End PBXBuildFile section */ @@ -129,6 +129,7 @@ 9CB55E9529A77FE700F6760A /* SettingTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingTableViewCell.swift; sourceTree = ""; }; 9CCFA4FD28F4585E00963A95 /* EventType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventType.swift; sourceTree = ""; }; 9CDBFCD0296C331C00357474 /* SettingConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingConfig.swift; sourceTree = ""; }; + A51AA36729A9A0B900FEE77D /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; A52F113C29A09FF4009FFE02 /* NoticeVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoticeVC.swift; sourceTree = ""; }; A52F113F29A0A02F009FFE02 /* NoticeCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoticeCoordinator.swift; sourceTree = ""; }; A52F114129A0A07D009FFE02 /* NoticeViewReactor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoticeViewReactor.swift; sourceTree = ""; }; @@ -215,7 +216,6 @@ E5B9965A28E2A16D00E39566 /* SortDropdownView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SortDropdownView.swift; sourceTree = ""; }; E5C9025128E2DB480086BDE9 /* HomeViewReactor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewReactor.swift; sourceTree = ""; }; E5CFF6F7297FD06C00E11D9A /* CVSStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CVSStorage.swift; sourceTree = ""; }; - E5D8019E29A70BC100A83CEE /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -519,7 +519,7 @@ BA27023228CF5EF30039D9EA /* Configuration */, BA27023328CF5EFF0039D9EA /* Sources */, E505D9F828CF5B4B00EEFC65 /* Info.plist */, - E5D8019E29A70BC100A83CEE /* GoogleService-Info.plist */, + A51AA36729A9A0B900FEE77D /* GoogleService-Info.plist */, A52F114329A0A2F1009FFE02 /* NoticeInfo.plist */, E53D1A3B2987EBE20074308B /* .swiftlint.yml */, ); @@ -665,12 +665,12 @@ A5932EA328E044CB00457AD3 /* onboarding1.json in Resources */, A54949D3296F052F00844828 /* noBookmark.json in Resources */, A5B69C3A2960095100052D2B /* Pretendard-Medium.otf in Resources */, + A51AA36829A9A0BA00FEE77D /* GoogleService-Info.plist in Resources */, A5932EA528E045EF00457AD3 /* onboarding3.json in Resources */, A5D5A6F12985629100AD4F6E /* EF_jejudoldam.otf in Resources */, A5932EA728E0472B00457AD3 /* onboarding2.json in Resources */, A5B69C392960095100052D2B /* Pretendard-ExtraBold.otf in Resources */, A5B69C372960095100052D2B /* Pretendard-Regular.otf in Resources */, - E5D8019F29A70BC100A83CEE /* GoogleService-Info.plist in Resources */, A5B69C342960095100052D2B /* Pretendard-Black.otf in Resources */, A5B69C322960095100052D2B /* Pretendard-Light.otf in Resources */, ); diff --git a/PPAK_CVS/Sources/AppDelegate.swift b/PPAK_CVS/Sources/AppDelegate.swift index c87b70b8..68ebe7ec 100644 --- a/PPAK_CVS/Sources/AppDelegate.swift +++ b/PPAK_CVS/Sources/AppDelegate.swift @@ -8,10 +8,19 @@ import UIKit import FirebaseCore +import FirebaseMessaging @main class AppDelegate: UIResponder, UIApplicationDelegate { + func application( + _ application: UIApplication, + willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil + ) -> Bool { + UNUserNotificationCenter.current().delegate = self + return true + } + func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? @@ -23,11 +32,31 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Set Firebase FirebaseApp.configure() + // FCM + Messaging.messaging().delegate = self + Messaging.messaging().token { token, error in + if let error = error { + print("Error fetching FCM registration token: \(error)") + } else if let token = token { + print("FCM registration token: \(token)") + } + } + + // User Notification Authorization + let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] + UNUserNotificationCenter.current().requestAuthorization( + options: authOptions, + completionHandler: { _, error in + print("Error request notifications Authorization: \(error.debugDescription)") + } + ) + application.registerForRemoteNotifications() + Thread.sleep(forTimeInterval: 1.0) return true } - // MARK: UISceneSession Lifecycle + // MARK: - UISceneSession Lifecycle func application( _ application: UIApplication, @@ -37,3 +66,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate { return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) } } + +// MARK: - FCM + +extension AppDelegate: UNUserNotificationCenterDelegate { + func userNotificationCenter( + _ center: UNUserNotificationCenter, + willPresent notification: UNNotification, + withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions + ) -> Void) { + completionHandler([.list, .banner, .badge, .sound]) + } +} + +extension AppDelegate: MessagingDelegate { + func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) { + print("Firebase registration token: \(String(describing: fcmToken))") + } +} From 0852bcd1df9550f8c2d9f7419d9c93ff88809e78 Mon Sep 17 00:00:00 2001 From: Minji Kim Date: Sat, 25 Feb 2023 11:16:18 +0900 Subject: [PATCH 2/3] [CHORE] hide bookmark info --- .../Scenes/Bookmark/BookmarkCollectionHeaderView.swift | 5 +++-- PPAK_CVS/Sources/Scenes/Bookmark/BookmarkVC.swift | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/PPAK_CVS/Sources/Scenes/Bookmark/BookmarkCollectionHeaderView.swift b/PPAK_CVS/Sources/Scenes/Bookmark/BookmarkCollectionHeaderView.swift index 3368906d..f5d914d2 100644 --- a/PPAK_CVS/Sources/Scenes/Bookmark/BookmarkCollectionHeaderView.swift +++ b/PPAK_CVS/Sources/Scenes/Bookmark/BookmarkCollectionHeaderView.swift @@ -76,9 +76,10 @@ final class BookmarkCollectionHeaderView: UICollectionReusableView { infoStack ].forEach { iconContainerView.addSubview($0) } + // NOTE: 찜한 제품의 알림 기능은 추후 업데이트 [ - mainLabel, - infoButton + mainLabel// , +// infoButton ].forEach { infoStack.addArrangedSubview($0) } } diff --git a/PPAK_CVS/Sources/Scenes/Bookmark/BookmarkVC.swift b/PPAK_CVS/Sources/Scenes/Bookmark/BookmarkVC.swift index 52efa62c..fd8ef238 100644 --- a/PPAK_CVS/Sources/Scenes/Bookmark/BookmarkVC.swift +++ b/PPAK_CVS/Sources/Scenes/Bookmark/BookmarkVC.swift @@ -172,6 +172,7 @@ final class BookmarkViewController: BaseViewController, View { .disposed(by: disposeBag) // 찜 정보 터치 + /* header.infoTouchView.rx.tapGesture() .skip(1) .bind { _ in @@ -180,6 +181,7 @@ final class BookmarkViewController: BaseViewController, View { self.present(popup, animated: false) } .disposed(by: disposeBag) + */ // 정렬조건 변경 sortDropdownView.sortSwitch From 2cb07ac259f6bfaf997ff8e29be0c9cd182b08f3 Mon Sep 17 00:00:00 2001 From: Minji Kim Date: Sat, 25 Feb 2023 20:42:11 +0900 Subject: [PATCH 3/3] [CHORE] some code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 홍승현 --- PPAK_CVS/Sources/AppDelegate.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/PPAK_CVS/Sources/AppDelegate.swift b/PPAK_CVS/Sources/AppDelegate.swift index 68ebe7ec..b2be948b 100644 --- a/PPAK_CVS/Sources/AppDelegate.swift +++ b/PPAK_CVS/Sources/AppDelegate.swift @@ -44,12 +44,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // User Notification Authorization let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] - UNUserNotificationCenter.current().requestAuthorization( - options: authOptions, - completionHandler: { _, error in + UNUserNotificationCenter.current().requestAuthorization(options: authOptions) { _, error in print("Error request notifications Authorization: \(error.debugDescription)") } - ) application.registerForRemoteNotifications() Thread.sleep(forTimeInterval: 1.0)