아래 부분처럼 바꾸어도 그대로네요…
(class AppDelegate: UIResponder, UIApplicationDelegate {)
class AppDelegate: UIResponder, UIApplicationDelegate {
@ObservedObject var appState = AppState.shared
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
// 'link' 키의 URL을 처리
if let link = userInfo["link"] as? String {
nativePush(path: link)
}
completionHandler()
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
Amplitude.instance().defaultTracking.sessions = true
let userId = UserDefaults.standard.string(forKey: "userId") ?? "null"
if(userId != "null"){
Amplitude.instance().setUserId(userId)
}
// 파이어베이스 설정
FirebaseApp.configure()
// 앱 실행 시 사용자에게 알림 허용 권한을 받음
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] // 필요한 알림 권한을 설정
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: { _, _ in }
)
// UNUserNotificationCenterDelegate를 구현한 메서드를 실행시킴
application.registerForRemoteNotifications()
// 파이어베이스 Meesaging 설정
Messaging.messaging().delegate = self
// Kakao SDK 초기화
KakaoSDK.initSDK(appKey: "20741c1f4d3ee4183acd95f528719b99")
return true
}
// 카카오 로그인 처리를 위한 URL 열기 메서드 추가
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
if AuthApi.isKakaoTalkLoginUrl(url) {
print("KAKAO 100")
return AuthController.handleOpenUrl(url: url)
}
print("KAKAO 101")
// 다른 URL 처리를 위한 코드 (필요한 경우)
return false
}
위에서 print(“KAKAO 100”) 과 KAKAO 101 모두 출력되지 않는걸로 봐서는 여기까지 오지못하는게 있는 것 같습니다.
mainView.swift 에서는 문제가 없는 것 같은데…
mainView.swift
@main
struct CampApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
SplashScreenView()
}
}
}