77
88import AuthenticationServices
99import UIKit
10+ import UserNotifications
1011
1112import Firebase
12- import UserNotifications
13+ import MTResource
1314
1415@main
1516class AppDelegate : UIResponder , UIApplicationDelegate {
16-
17-
18-
17+
18+
19+
1920 func application( _ application: UIApplication , didFinishLaunchingWithOptions launchOptions: [ UIApplication . LaunchOptionsKey : Any ] ? ) -> Bool {
2021 getCredentialState ( )
2122 FirebaseApp . configure ( )
22-
23+
2324 Messaging . messaging ( ) . delegate = self
2425 UNUserNotificationCenter . current ( ) . delegate = self
2526 let authOptions : UNAuthorizationOptions = [ . alert, . badge, . sound]
26-
27+
2728 UNUserNotificationCenter . current ( ) . requestAuthorization ( options: authOptions) { _, _ in }
2829 application. registerForRemoteNotifications ( )
2930 return true
3031 }
31-
32+
3233 // MARK: UISceneSession Lifecycle
33-
34+
3435 func application( _ application: UIApplication , configurationForConnecting connectingSceneSession: UISceneSession , options: UIScene . ConnectionOptions ) -> UISceneConfiguration {
3536 // Called when a new scene session is being created.
3637 // Use this method to select a configuration to create the new scene with.
3738 return UISceneConfiguration ( name: " Default Configuration " , sessionRole: connectingSceneSession. role)
3839 }
39-
40+
4041 func application( _ application: UIApplication , didDiscardSceneSessions sceneSessions: Set < UISceneSession > ) {
4142 // Called when the user discards a scene session.
4243 // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
4344 // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
4445 }
45-
46+
4647 func application( _ application: UIApplication , supportedInterfaceOrientationsFor window: UIWindow ? ) -> UIInterfaceOrientationMask {
4748 return UIInterfaceOrientationMask . portrait
4849 }
@@ -51,17 +52,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5152 print ( " applicationWillEnterForeground " )
5253 getCredentialState ( )
5354 }
54-
55+
5556 func applicationDidBecomeActive( _ application: UIApplication ) {
5657 print ( " applicationDidBecomeActive " )
5758 getCredentialState ( )
5859 }
5960
6061 func application( _ application: UIApplication , didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data ) {
61- let deviceTokenString = deviceToken. reduce ( " " , { $0 + String( format: " %02X " , $1) } )
62- print ( " [Log] deviceToken : " , deviceTokenString)
62+ let deviceTokenString = deviceToken. reduce ( " " , { $0 + String( format: " %02X " , $1) } )
63+ print ( " [Log] deviceToken : " , deviceTokenString)
6364
64- Messaging . messaging ( ) . apnsToken = deviceToken
65+ Messaging . messaging ( ) . apnsToken = deviceToken
6566 }
6667}
6768
@@ -93,14 +94,14 @@ extension AppDelegate: MessagingDelegate {
9394 print ( " 파이어베이스 토큰: \( fcmToken ?? " " ) " )
9495 guard let token = fcmToken else { return }
9596 UserDefaultHandler . setFcmToken ( fcmToken: token)
96- }
97+ }
9798}
9899
99100extension AppDelegate : UNUserNotificationCenterDelegate {
100101 func userNotificationCenter( _ center: UNUserNotificationCenter , willPresent notification: UNNotification , withCompletionHandler completionHandler: @escaping ( UNNotificationPresentationOptions ) -> Void ) {
101102 completionHandler ( [ . badge, . sound] )
102- }
103-
103+ }
104+
104105 func userNotificationCenter( _ center: UNUserNotificationCenter , didReceive response: UNNotificationResponse , withCompletionHandler completionHandler: @escaping ( ) -> Void ) {
105106 guard let sceneDelegate = UIApplication . shared. connectedScenes. first? . delegate
106107 as? SceneDelegate else { return }
0 commit comments