Kakao Talk not returning callback when user gives permission to Kakao Talk and do sign in to Kakao Talk

Hi,

When we try to call loginWithKakaoTalk and permission is not given to Kakao Talk application. There is no callback from Kakao Talk when permission is given and user is signed in. User comes to client application by pressing back button. When request comes back to client application is there any way to differentiate between below scenarios :

  1. User has given permission to Kakao Talk
  2. User has intentionally pressed back button
  3. User has not given permission to Kakao Talk

Below is code that I am using, please help how I can return callback in case of above scenario or how to handle above scenario as part of below code. Is there any other scenario that I need to handle as well :

Version used : group = “com.kakao.sdk.v2-user” 2.20.3
override fun login(activity: Activity, callback: KakaoLoginCallback) {

    if (UserApiClient.instance.isKakaoTalkLoginAvailable(activity)) {
        loginWithKakaoTalk(activity, callback)
    } else {
        loginWithKakaoAccount(activity, callback)
    }

}

private fun loginWithKakaoTalk(
    activity: Activity,
    callback: KakaoLoginCallback
) {
    UserApiClient.instance.loginWithKakaoTalk(activity) { token, error ->
        if (error != null) {
            println("Kakao : $error")
            if (error is ClientError && error.reason == ClientErrorCause.Cancelled) {
                /*
                This case comes when user has not given permission to Kakao talk .
                After user given permission we will re-try to do Kakao Talk login.
                 */
                checkIfUserHasGivenPermissionToKakaoTalk(activity, callback)
            } else {
                /*
                If there is any other error for Kakao Talk login we will fallback to Kakao
                account login
                 */
                loginWithKakaoAccount(activity, callback)
            }
        } else if (token != null) {
            callback.onKakaoLoginSuccess(token.accessToken)
        }
    }
}

private fun checkIfUserHasGivenPermissionToKakaoTalk(
    activity: Activity,
    callback: KakaoLoginCallback
) {
    UserApiClient.instance.loginWithKakaoTalk(activity) { token, error ->
        if (error != null) {
            println("Kakao : $error")
            if (error is ClientError && error.reason == ClientErrorCause.Cancelled) {
                callback.onKakaoLoginCancel()
            } else {
                /*
              If there is any other error for Kakao Talk login we will fallback to Kakao
                account login
             */
                loginWithKakaoAccount(activity, callback)
            }
        }else if (token != null) {
            callback.onKakaoLoginSuccess(token.accessToken)
        }
    }
}

private fun loginWithKakaoAccount(
    activity: Activity,
    callback: KakaoLoginCallback
) {
    UserApiClient.instance.loginWithKakaoAccount(activity) { token, error ->
        handleAccessToken(token, error, callback)
    }
}

private fun handleAccessToken(token: OAuthToken?, error: Throwable?, callback: KakaoLoginCallback) {
    if (error != null) {
        handleAccessTokenError(error, callback)
    } else if (token != null) {
        callback.onKakaoLoginSuccess(token.accessToken)
    }
}

private fun handleAccessTokenError(
    error: Throwable?,
    callback: KakaoLoginCallback
) {
    if (error is ClientError && error.reason == ClientErrorCause.Cancelled) {
        callback.onKakaoLoginCancel()
    } else {
        if (error != null) {
            callback.onKakaoLoginError(Exception(error.message))
        }
    }
}

문의 시, 사용하시는 SDK 버전 정보와 디벨로퍼스 앱ID를 알려주세요.

Faq 목록 - 10. Android ( Faq 목록 입니다 ) 먼저 확인해주세요.


Hi~

Tell me your app ID.
(My Application>App Settings>Summary > ID)

App ID : 1099869

Hello,

Please share your AndroidManifest.xml file.

Please find below AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application>
        <activity android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
            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" />

                <data android:scheme="@string/kakao_login_app_scheme" android:host="oauth" />
            </intent-filter>
        </activity>
    </application>
</manifest>

Please test by directly assigning values without referencing any resources.

I have tested with directly assigning values as well. It works for the scenario when user is logged into Kakao Talk and only below scenario fails :

In below scenario we are not getting callback :

  1. Initial permission is not given to Kakao Talk - Phone, Contacts, Storage
  2. When we click on login button, user gives permission to Kakao talk and signs to Kakao
  3. After sign in successful, callback to not send to client application

I now understand the situation. Thank you for the detailed explanation.

In this scenario, it has been identified that after the user grants permission, the user authentication and callback are not functioning properly.

This is a known issue that occurs because the flow for essential app permissions and the Kakao login flow are treated differently.

I will forward this internally to see if it can be improved.

So, as per current code do you suggest any improvement to handle below cases :

  1. User has given permission to Kakao Talk
  2. User has intentionally pressed back button
  3. User has not given permission to Kakao Talk

This issue requires improvements to KakaoTalk’s functionality. However, since such edge cases are not common, we cannot provide a timeline for improvements at this stage.

Unfortunately, for now, please proceed with development while disregarding this case.