[플러터] supabase를 통한 카카오 로그인 오류

문의 시 사용하시는 SDK 버전 정보와 플랫폼(Android / iOS) 및 디벨로퍼스 앱ID를 알려주세요.


SDK: kakao_flutter_sdk_user: ^1.8.0
앱ID: 1011033


플러터로 supabase에 유저 등록을 하기위해 카카오 로그인을 사용하였습니다.
먼저 IOS와 Android 둘다 유저 등록은 가능한 상태입니다.

하지만, IOS는 카카오 로그인 웹뷰에서 로그인 후 앱으로 돌아오면 Supabase sign In이 적용됩니다만,
Android의 경우는 앱으로 돌아오면서 E/IllegalArgumentException(16304): java.lang.IllegalArgumentException: No uri was passed to CustomTabsActivity. 문구가 뜨면서 sign in이 적용이 되지않습니다.

androidmanifest.xml에는 현재 아래 코드를 적용시켜 사용하고있습니다.

<activity 
            android:name="com.kakao.sdk.flutter.AuthCodeCustomTabsActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <!-- 카카오 로그인 Redirect URI -->
                <data 
                    android:scheme="kakao${KAKAO_NATIVE_APP_KEY}" 
                    android:host="oauth"/>
            </intent-filter>
        </activity>

로그인 적용하는 코드는 현재

await supabase.client.auth.signInWithOAuth(
      OAuthProvider.kakao,
      authScreenLaunchMode: LaunchMode.externalApplication,
      redirectTo: 'kakao${dotenv.get('KAKAO_NATIVE_APP_KEY')}://oauth',
 );

이렇게 사용하고 있습니다.

안녕하세요

supabase에 sign in을 위함이라면 kakao_flutter_sdk_user 패키지를 사용하실 필요가 없어보입니다.
supabase 가이드를 확인해보시면 로그인 후에 앱으로 돌아오기 위한 목적으로 <intent-filter>를 등록하고 있습니다.

그런데 com.kakao.sdk.flutter.AuthCodeCustomTabsActivity는 kakao_flutter_sdk 로그인 기능을 실행할 때, 서버로부터 인가코드를 전달받기 위해 사용하는 Activity이므로 supabase 로그인을 할 때는 정상적으로 동작하지 않을 수 있습니다.

android 플랫폼 단에 별도로 Activity를 구현한 것이 아니라면 아래와 같이 MainActivity에 <intent-filter>를 등록하면 정상적으로 동작할 것으로 보입니다. (아래의 내용에서 ${APP_KEY}은 signInWithOAuth에서 redirectTo 파라미터에 전달한 앱 키를 등록해야합니다)

그리고 위에서 언급했던 것과 같이 supabase에서는 단순히 앱으로 다시 돌아오기 위해 <intent-filter>를 등록하는 것이므로 kakao${APP_KEY}://oauth 형태가 아닌 커스텀 스킴을 사용해도 정상적으로 동작이 가능한 점 참고 부탁드립니다

<activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:exported="true"
            android:hardwareAccelerated="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
                android:name="io.flutter.embedding.android.NormalTheme"
                android:resource="@style/NormalTheme" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="oauth"
                    android:scheme="kakao${APP_KEY}" />
            </intent-filter>
        </activity>