Skip to content

Commit c474d2f

Browse files
committed
[BOOK-365] fix: adjust timing of system notification permission request
1 parent b0f0f2e commit c474d2f

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/Projects/BKPresentation/Sources/AppCoordinator.swift

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import BKDesign
66
import Combine
77
import Foundation
88
import UIKit
9+
import UserNotifications
910

1011
public final class AppCoordinator: Coordinator, AuthenticationRequiredNotifying, ScreenLoggable {
1112
public var screenName: String = GATracking.OnboardingAndAuth.splash
@@ -120,9 +121,10 @@ public final class AppCoordinator: Coordinator, AuthenticationRequiredNotifying,
120121

121122
loginCoordinator.onFinish = { [weak self] in
122123
guard let self else { return }
123-
124+
124125
self.navigationController.dismiss(animated: animated)
125126
AccessModeCenter.shared.mode.send(.member)
127+
self.requestNotificationPermissionIfNeeded()
126128
self.checkAuthAndRoute()
127129
onFinishAuth?()
128130
}
@@ -210,11 +212,25 @@ public final class AppCoordinator: Coordinator, AuthenticationRequiredNotifying,
210212
leftButtonAction: AppStoreLinker.openAppStore
211213
)
212214
)
213-
215+
214216
let dialogViewController = BKDialogViewController(dialog: dialog)
215217
dialogViewController.isModalInPresentation = true
216218
DispatchQueue.main.async {
217219
self.navigationController.present(dialogViewController, animated: true)
218220
}
219221
}
222+
223+
private func requestNotificationPermissionIfNeeded() {
224+
UNUserNotificationCenter.current().getNotificationSettings { settings in
225+
// 아직 권한을 요청하지 않았을 때만 요청
226+
guard settings.authorizationStatus == .notDetermined else { return }
227+
228+
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { granted, _ in
229+
guard granted else { return }
230+
DispatchQueue.main.async {
231+
UIApplication.shared.registerForRemoteNotifications()
232+
}
233+
}
234+
}
235+
}
220236
}

src/Projects/Booket/Sources/AppDelegate.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,9 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
2929
#endif
3030
KakaoSDK.initSDK(appKey: kakaoAPIkey)
3131
FirebaseApp.configure()
32-
32+
3333
GAManager.configureAnalytics()
3434
UNUserNotificationCenter.current().delegate = self
35-
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { granted, _ in
36-
guard granted else { return }
37-
DispatchQueue.main.async {
38-
UIApplication.shared.registerForRemoteNotifications()
39-
}
40-
}
4135
Messaging.messaging().delegate = self
4236

4337
return true

0 commit comments

Comments
 (0)