Skip to content

Commit

Permalink
Merge pull request #97 from S-FAM/feat/FCM
Browse files Browse the repository at this point in the history
FCM(Firebase Cloud Messaging) 구현
  • Loading branch information
WhiteHyun authored Feb 25, 2023
2 parents 43127a7 + 2cb07ac commit b8426d6
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 7 deletions.
8 changes: 4 additions & 4 deletions PPAK_CVS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 */

Expand All @@ -129,6 +129,7 @@
9CB55E9529A77FE700F6760A /* SettingTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingTableViewCell.swift; sourceTree = "<group>"; };
9CCFA4FD28F4585E00963A95 /* EventType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventType.swift; sourceTree = "<group>"; };
9CDBFCD0296C331C00357474 /* SettingConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingConfig.swift; sourceTree = "<group>"; };
A51AA36729A9A0B900FEE77D /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
A52F113C29A09FF4009FFE02 /* NoticeVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoticeVC.swift; sourceTree = "<group>"; };
A52F113F29A0A02F009FFE02 /* NoticeCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoticeCoordinator.swift; sourceTree = "<group>"; };
A52F114129A0A07D009FFE02 /* NoticeViewReactor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoticeViewReactor.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -215,7 +216,6 @@
E5B9965A28E2A16D00E39566 /* SortDropdownView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SortDropdownView.swift; sourceTree = "<group>"; };
E5C9025128E2DB480086BDE9 /* HomeViewReactor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewReactor.swift; sourceTree = "<group>"; };
E5CFF6F7297FD06C00E11D9A /* CVSStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CVSStorage.swift; sourceTree = "<group>"; };
E5D8019E29A70BC100A83CEE /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -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 */,
);
Expand Down Expand Up @@ -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 */,
);
Expand Down
46 changes: 45 additions & 1 deletion PPAK_CVS/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]?
Expand All @@ -23,11 +32,28 @@ 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) { _, 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,
Expand All @@ -37,3 +63,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))")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ final class BookmarkCollectionHeaderView: UICollectionReusableView {
infoStack
].forEach { iconContainerView.addSubview($0) }

// NOTE: 찜한 제품의 알림 기능은 추후 업데이트
[
mainLabel,
infoButton
mainLabel// ,
// infoButton
].forEach { infoStack.addArrangedSubview($0) }
}

Expand Down
2 changes: 2 additions & 0 deletions PPAK_CVS/Sources/Scenes/Bookmark/BookmarkVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ final class BookmarkViewController: BaseViewController, View {
.disposed(by: disposeBag)

// 찜 정보 터치
/*
header.infoTouchView.rx.tapGesture()
.skip(1)
.bind { _ in
Expand All @@ -179,6 +180,7 @@ final class BookmarkViewController: BaseViewController, View {
self.present(popup, animated: false)
}
.disposed(by: disposeBag)
*/

// 정렬조건 변경
sortDropdownView.sortSwitch
Expand Down

0 comments on commit b8426d6

Please sign in to comment.