플러터 ios 카카오톡 로그인이 가밪기 되지 않습니다

디벨로퍼스 앱 ID: 775109

ios 설정은 모두 다 해줬고,

 kakao.User? user =
          await ref.read(userProvider.notifier).kakaoLogin(context);


  Future<kakao.User?> kakaoLogin(BuildContext context) async {
    bool kakaoLoggedIn = await _kakaoLogin.login();

    if (kakaoLoggedIn) {
      try {
        user = await kakao.UserApi.instance.me();

        final customToken = await _firebaseAuthDatabase.createCustomToken({
          'uid': user!.id.toString(),
          'displayName': user!.kakaoAccount?.profile?.nickname ?? "-",
          'photoURL': user!.kakaoAccount?.profile?.profileImageUrl ?? "-",
        });

        await _authRepo.signinWithCustomToken(customToken);

        return user;
      } catch (error) {
        // ignore: avoid_print
        print("kakaoLogin -> $error");
      }
    }

    return null;
  }

Future<bool> login() async {
    try {
      bool isInstalled = await isKakaoTalkInstalled();

      if (isInstalled) {
        // 로그인
        try {
          // 로그인
          await UserApi.instance.loginWithKakaoTalk();
          return true;
        } catch (error) {
          if (error is PlatformException && error.code == "CANCELED") {
            return false;
          }

          try {
            await UserApi.instance.loginWithKakaoAccount();
            return true;
          } catch (error) {
            return false;
          }
        }
      } else {
        // 로그인 x
        try {
          // 토큰 생성
          await UserApi.instance.loginWithKakaoAccount();
          return true;
        } catch (error) {
          return false;
        }
      }
    } catch (error) {
      // 설치 여부 체크 x

      return false;
    }
  }

  @override
  Future<bool> logout() async {
    try {
      await UserApi.instance.unlink();
      return true;
    } catch (error) {
      return false;
    }
  }

기존의 위의 코드로 모두 정상 작동되고 있었습니다.

그런데 가장 하단의 login() 부분에서
bool isInstalled = await isKakaoTalkInstalled();
까지만 체크가되고

그 아래

await UserApi.instance.loginWithKakaoTalk();

호출이 되지 않고 멈춥니다.

Snapshot request 0x301895620 complete with error: <NSError: 0x301896520; domain: FBSSceneSnapshotErrorDomain; code: 3; "the request was canceled"> {
    NSLocalizedDescription = an error occurred during a scene snapshotting operation;
}
Snapshot request 0x301895620 complete with error: <NSError: 0x301897000; domain: BSActionErrorDomain; code: 6 ("anulled")>


flutter: ***** SupabaseAuthState handleDeeplink kakao~~~~://oauth?code=Rq88krADPhjdKVCEV1d7dyhCEOPj61tqd9IUVz5ZSyUToCNqJPn9dgAAAAQKPXNOAAABkSX0G49PBWDH3LuH7A
flutter: onReceivedAuthDeeplink uri: kakao~~~~://oauth?code=Rq88krADPhjdKVCEV1d7dyhCEOPj61tqd9IUVz5ZSyUToCNqJPn9dgAAAAQKPXNOAAABkSX0G49PBWDH3LuH7A
flutter: AuthException(message: Code verifier could not be found in local storage., statusCode: null)
flutter: #0      GoTrueClient.exchangeCodeForSession (package:gotrue/src/gotrue_client.dart:329:7)
flutter: <asynchronous suspension>
flutter: #1      GoTrueClient.getSessionFromUrl (package:gotrue/src/gotrue_client.dart:770:14)
flutter: <asynchronous suspension>
flutter: #2      SupabaseAuth._handleDeeplink (package:supabase_flutter/src/supabase_auth.dart:227:7)
flutter: <asynchronous suspension>
flutter: AuthException(message: Code verifier could not be found in local storage., statusCode: null)
flutter: #0      GoTrueClient.exchangeCodeForSession (package:gotrue/src/gotrue_client.dart:329:7)
flutter: <asynchronous suspension>
flutter: #1      GoTrueClient.getSessionFromUrl (package:gotrue/src/gotrue_client.dart:770:14)
flutter: <asynchronous suspension>
flutter: #2      SupabaseAuth._handleDeeplink (package:supabase_flutter/src/supabase_auth.dart:227:7)
flutter: <asynchronous suspension>
10.28.0 - [FirebaseAnalytics][I-ACS023001] Deep Link does not contain valid required params. URL params: {
    code = Rq88krADPhjdKVCEV1d7dyhCEOPj61tqd9IUVz5ZSyUToCNqJPn9dgAAAAQKPXNOAAABkSX0G49PBWDH3LuH7A;
}

제가 받는 에러 메세지는 위와 같아요.

슈파베이스를 백으로 사용하지만 authentication 로그인은 파이어베이스를 사용하는데 SupabaseAuth에서 에러 로그를 찍는것도 좀 이상하고,

에러 로그에 deeplink가 찍히는걸로 봐서는… branch.io 통해서 사용하려고 했었는데 그 영향으로 문제가 발생한건지 모르겠어요.
branch에서 제공하는 url scheme을 추가하긴 했거든요.

그래도 기존 kakao scheme은 건드리지 않았는데ㅠㅠ

참고차 AppDelegate.swift 파일도 공유합니다.

import UIKit
import Flutter
// import workmanager
import app_links
import flutter_background_service_ios

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    SwiftFlutterBackgroundServicePlugin.taskIdentifier = "dev.flutter.background.refresh"

    if let url = AppLinks.shared.getLink(launchOptions: launchOptions) {
    // We have a link, propagate it to your Flutter app or not
    AppLinks.shared.handleLink(url: url)
    return true // Returning true will stop the propagation to other packages
   }

    // WorkmanagerPlugin.registerTask(withIdentifier: "task-identifier")
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

안녕하세요

이전에 AppLinks 측 버그로 인해 로그인이 정상적으로 동작하지 않는 경우가 있었습니다.

비슷한 케이스일 수 있어보여서 확인 부탁드리겠습니다

@tony.mb app_links 패키지를 모두 지우고 캐시도 지우고 실행해봐도 동일한 현상이 반복됩니다 ㅠ

AppDelegate 파일도

import UIKit
import Flutter
// import workmanager
// import app_links
import flutter_background_service_ios

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    SwiftFlutterBackgroundServicePlugin.taskIdentifier = "dev.flutter.background.refresh"

  //   if let url = AppLinks.shared.getLink(launchOptions: launchOptions) {
  //   // We have a link, propagate it to your Flutter app or not
  //   AppLinks.shared.handleLink(url: url)
  //   return true // Returning true will stop the propagation to other packages
  //  }

    // WorkmanagerPlugin.registerTask(withIdentifier: "task-identifier")
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

아예 링크 처리하는 부분을 없앴는데도 로그인이 안돼요 ㅠ

pubspec.yaml 파일 첨부 부탁드리겠습니다.

최근에 flutter_branch_sdk 사용시에 로그인이 실패한다는 제보가 있었어서 비슷한 케이스일 가능성도 있어보여요

name: onldocc_flutter
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: "none" # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 3.6.5

environment:
  sdk: ">=3.0.0-286.0.dev <4.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter

  flutter_localizations:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  lottie: ^3.1.0
  flutter_animate: ^4.2.0+1
  font_awesome_flutter: ^10.4.0
  dropdown_button2: ^2.1.4
  flutter_svg: ^2.0.7
  xml: ^6.3.0
  flutter_launcher_icons: ^0.13.1
  firebase_core: ^3.0.0
  firebase_auth: ^5.0.0
  cloud_firestore: ^5.0.0
  cloud_functions: ^5.0.0
  firebase_storage: ^12.0.0
  firebase_messaging: ^15.0.0
  firebase_remote_config: ^5.0.0
  flutter_riverpod: ^2.3.7
  image_picker: ^1.0.2
  flutter_multi_formatter: ^2.11.7
  intl: ^0.19.0
  change_app_package_name: ^1.1.0
  kakao_flutter_sdk_user: ^1.5.0
  kakao_flutter_sdk_share: ^1.5.0
  http: ^1.1.2
  pedometer: ^4.0.1
  permission_handler: ^11.3.0
  flutter_background_service: ^5.0.6
  flutter_local_notifications: ^17.1.2
  shared_preferences: ^2.2.0
  provider: ^6.0.5
  dart_date: ^1.2.2
  chat_gpt_sdk: ^3.0.4
  loading_animation_widget: ^1.2.0+4
  speech_to_text: ^6.1.1
  file_picker: ^8.0.0+1
  cached_network_image: ^3.2.3
  video_player: ^2.7.1
  package_info_plus: ^8.0.0
  url_launcher: ^6.1.11
  youtube_player_flutter: ^9.0.0
  flutter_dotenv: ^5.1.0
  dart_openai: ^5.1.0
  flutter_keyboard_visibility: ^6.0.0
  video_thumbnail: ^0.5.3
  transparent_image: ^2.0.1
  path_provider: ^2.1.2
  flutter_background_service_ios: ^5.0.0
  sign_in_with_apple: ^6.0.0
  debounce_throttle: ^2.0.0
  easy_debounce: ^2.0.3
  path: ^1.8.3
  audioplayers: ^6.0.0
  flutter_tts: ^4.0.2
  uuid: ^4.2.1
  supabase_flutter: ^2.5.6
  animated_splash_screen: ^1.3.0
  collection: ^1.18.0
  recaptcha_enterprise_flutter: ^18.4.2
  mailer: ^6.0.1
  connectivity_plus: ^6.0.1
  device_info_plus: ^10.0.1
  timezone: ^0.9.2
  table_calendar: ^3.0.9
  fl_chart: ^0.68.0
  android_alarm_manager_plus: ^4.0.1
  sentry_flutter: ^8.2.0
  siri_wave: ^2.0.0+1
  noise_meter: ^5.0.2
  firebase_analytics: ^11.0.0
  flutter_inappwebview: ^6.0.0
  webview_flutter: ^4.7.0
  flutter_cache_manager: ^3.3.2
  flutter_skeleton_ui: ^0.0.6
  go_router: ^14.2.0
  flutter_branch_sdk: ^7.1.0
  dio_cache_interceptor: ^3.5.0
  dio: ^5.4.3+1
  dio_cache_interceptor_hive_store: ^3.2.2
  hive: ^2.2.3
  flutter_sound: ^9.6.0
  googleapis_auth: ^1.6.0
  chewie: ^1.8.2

  # flutter_sms:
  #   git:
  #     url: https://github.com/fluttercommunity/flutter_sms.git
  #     ref: master

dependency_overrides:
  webview_flutter_android: 3.16.1

dev_dependencies:
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^4.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:
  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - .env
    - assets/
    - assets/anims/
    - assets/new_icons/
    - assets/menus/
    - assets/svg/
    - assets/svg_2/
    - assets/mood_3d/
    - assets/jpg/
    - assets/number/
    - assets/setting_img/
    - assets/app_intro/
    - assets/image_2/
    - assets/permissions/
    - shorebird.yaml

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    # - family: NanumSquare
    #   fonts:
    #     - asset: assets/fonts/NanumSquareNeoOTF-Hv.otf
    #       weight: 800
    #     - asset: assets/fonts/NanumSquareNeoOTF-Eb.otf
    #       weight: 700
    #     - asset: assets/fonts/NanumSquareNeoOTF-Bd.otf
    #       weight: 600
    #     - asset: assets/fonts/NanumSquareNeoOTF-Rg.otf
    #       weight: 500
    #     - asset: assets/fonts/NanumSquareNeoOTF-Lt.otf
    #       weight: 400
    - family: Pretendard
      fonts:
        - asset: assets/fonts/Pretendard-Bold.otf
          weight: 700
        - asset: assets/fonts/Pretendard-SemiBold.otf
          weight: 600
        - asset: assets/fonts/Pretendard-Medium.otf
          weight: 500
        - asset: assets/fonts/Pretendard-Regular.otf
          weight: 400
        


  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

에러 가운데

AuthException(message: Code verifier could not be found in local storage., statusCode: null)

를 보면 loginWithKakaoTalk의

final authCode = await AuthCodeClient.instance.authorizeWithTalk(
  redirectUri: redirectUrl ?? KakaoSdk.redirectUri,
  channelPublicId: channelPublicIds,
  serviceTerms: serviceTerms,
  codeVerifier: codeVerifier,
  nonce: nonce,
  stateToken: stateToken,
  webPopupLogin: true,
);

여기 부분에서 codeVerifier가 null이라는거 같은데… 뭐가 문제일까요ㅠ

타 플러그인에서 카카오 로그인용 커스텀 스킴을 가로채고 있는 것으로 보여요.

flutter_branch_sdk 제거했을 때는 정상동작하는지, 빈 프로젝트에 카카오SDK만 추가했을 때 정상적으로 로그인되는지 확인가능할까요?

말씀주신대로 flutter_branch_sdk 패키지 제거하니까 정상 작동하네요…
우선 사용을 안 하도록 하겠습니다! 확인 감사드립니다.

1개의 좋아요