Skip to content

Commit 2a5a1e2

Browse files
authored
[#138] 앱델리의 print 문을 Logger로 대체한다
1 parent a6f9a79 commit 2a5a1e2

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

DevLog/App/Delegate/AppDelegate.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// Created by opfic on 5/7/25.
66
//
77

8-
import Combine
98
import UIKit
109
import Firebase
1110
import FirebaseAuth
@@ -15,6 +14,7 @@ import GoogleSignIn
1514
import UserNotifications
1615

1716
class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate {
17+
private let logger = Logger(category: "AppDelegate")
1818
func application(
1919
_ app: UIApplication,
2020
open url: URL,
@@ -33,9 +33,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate {
3333
UNUserNotificationCenter.current().delegate = self
3434
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { granted, error in
3535
if let error = error {
36-
print("Notification authorization error: \(error)")
36+
self.logger.error("Notification authorization error", error: error)
3737
} else {
38-
print("Notification permission granted: \(granted)")
38+
self.logger.info("Notification permission granted: \(granted)")
3939
DispatchQueue.main.async {
4040
UIApplication.shared.registerForRemoteNotifications()
4141
}
@@ -61,23 +61,23 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate {
6161
_ application: UIApplication,
6262
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
6363
) {
64-
print("APNs token: \(deviceToken.map { String(format: "%02.2hhx", $0) }.joined())")
64+
logger.info("APNs token: \(deviceToken.map { String(format: "%02.2hhx", $0) }.joined())")
6565
Messaging.messaging().apnsToken = deviceToken
6666
}
6767

6868
// APNs 등록 실패
6969
func application(
7070
_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error
7171
) {
72-
print("Failed to register APNs Token: \(error)")
72+
logger.error("Failed to register APNs token", error: error)
7373
}
7474

7575
// FCMToken 갱신
7676
func messaging(
7777
_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?
7878
) {
7979
if let fcmToken = fcmToken {
80-
print("FCM token: \(fcmToken)")
80+
logger.info("FCM token: \(fcmToken)")
8181
NotificationCenter.default.post(name: .fcmToken, object: nil, userInfo: ["fcmToken": fcmToken])
8282
}
8383
}
@@ -90,7 +90,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate {
9090

9191
try await settingsRef.setData(["timeZone": TimeZone.autoupdatingCurrent.identifier], merge: true)
9292
} catch {
93-
print("Failed to update timeZone: \(error)")
93+
logger.error("Failed to update timeZone", error: error)
9494
}
9595
}
9696
}
@@ -103,7 +103,7 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
103103
willPresent notification: UNNotification,
104104
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
105105
) {
106-
print("Foreground notification: \(notification.request.content.userInfo)")
106+
logger.info("Foreground notification: \(notification.request.content.userInfo)")
107107
completionHandler([.banner, .sound, .badge])
108108
}
109109

@@ -113,7 +113,7 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
113113
didReceive response: UNNotificationResponse,
114114
withCompletionHandler completionHandler: @escaping () -> Void
115115
) {
116-
print("Tapped notification: \(response.notification.request.content.userInfo)")
116+
logger.info("Tapped notification: \(response.notification.request.content.userInfo)")
117117
// userInfo["todoId"]로 이동할 Todo 식별
118118
let userInfo = response.notification.request.content.userInfo
119119
NotificationCenter.default.post(name: .pushTapped, object: nil, userInfo: userInfo)

0 commit comments

Comments
 (0)