플러터에서 authentication tokens not exist

플러터로 연동 로그인 개발하고있습니다.

앱 아이디 1240483

loginWithKakaoAccount는 문제없이작동하지만 loginWithKakaoTalk에서 문제가 생깁니다

2025-05-10 01:36:59926 [:bangbang:][AuthRequestRetrier.swift 40:25] → request retrier:
error:requestAdaptationFailed(error: KakaoSDKCommon.SdkError.ClientFailed(reason: KakaoSDKCommon.ClientFailureReason.TokenNotFound, errorMessage: Optional(“authentication tokens not exist.”)))
not api error → pass through

2025-05-10 01:36:59927 [:bangbang:][AuthRequestRetrier.swift 119:21] → request retrier:
not handled error → pass through

2025-05-10 01:36:59928 [:bangbang:][Api.swift 151:29] → response:
api error: ClientFailed(reason: KakaoSDKCommon.ClientFailureReason.TokenNotFound, errorMessage: Optional(“authentication tokens not exist.”))

AppDelegate

import Flutter
import UIKit
import Firebase
import FirebaseMessaging
import flutter_local_notifications
// 카카오 SDK 임포트 추가
import KakaoSDKCommon
import KakaoSDKAuth

@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) → Bool {
// 카카오 SDK 초기화 추가
KakaoSDK.initSDK(appKey: “”)

FirebaseApp.configure()
Messaging.messaging().delegate = self

if #available(iOS 10.0, *) {
  UNUserNotificationCenter.current().delegate = self
}

FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
    GeneratedPluginRegistrant.register(with: registry)
}

application.registerForRemoteNotifications()
Messaging.messaging().token { token, error in
    if let token = token {
        print("FCM 토큰(앱 시작 시): \(token)")
    } else if let error = error {
        print("FCM 토큰 에러: \(error)")
    }
}

GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)

}

// 카카오 로그인 콜백 처리 메서드 추가
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) → Bool {
if (AuthApi.isKakaoTalkLoginUrl(url)) {
return AuthController.handleOpenUrl(url: url)
}
return super.application(app, open: url, options: options)
}

override func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
Messaging.messaging().apnsToken = deviceToken
Messaging.messaging().token { token, error in
if let token = token {
print(“FCM 토큰(APNs 토큰 설정 후): (token)”)
} else if let error = error {
print(“FCM 토큰 갱신 에러: (error)”)
}
}
}

override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print(“푸시 알림 등록 실패: (error.localizedDescription)”)
}

override func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) → Void) {
let userInfo = notification.request.content.userInfo
if let messageID = userInfo[“gcm.message_id”] {
print(“포그라운드 상태에서 메시지 수신, 메시지 ID: (messageID)”)
}

if #available(iOS 14.0, *) {
  completionHandler([[.banner, .sound, .badge]])
} else {
  completionHandler([[.alert, .sound, .badge]])
}

}

override func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () → Void) {
let userInfo = response.notification.request.content.userInfo
if let messageID = userInfo[“gcm.message_id”] {
print(“알림을 탭했습니다, 메시지 ID: (messageID)”)
}
super.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
}
}

extension AppDelegate: MessagingDelegate {
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
print(“FCM 토큰: (String(describing: fcmToken))”)

if let token = fcmToken {
  let dataDict: [String: String] = ["token": token]
  NotificationCenter.default.post(
    name: Notification.Name("FCMToken"),
    object: nil,
    userInfo: dataDict
  )
}

}
}

initSDK키는 뺴고 전달드립니다.
무엇이 문제인지 모르겠습니다.

문서를 통해 해결한 주제입니다.

override func application(_ app: UIApplication,
부분을

13버전 전용으로 변경처리 iOS | Kakao Developers iOS

1개의 좋아요

참고. 카카오톡으로 로그인을 위한 설정