line / line-sdk-android

LINE SDK for Android lets you integrate LINE into your Android app to create a more engaging experience for your users.
https://developers.line.biz/en/docs/android-sdk/
Apache License 2.0
133 stars 45 forks source link

Line LoginButton LoginListener seem not call ( use Sample Code) #130

Closed DeyuGoGo closed 1 year ago

DeyuGoGo commented 1 year ago

I use the sample code for login , but I don't get the login result from loginListener 。

@Composable
fun LineLoginButton(
    channelId: String,
    modifier: Modifier = Modifier,
    handleLoginResult: (result: LineLoginResult) -> Unit
) {
    val loginListener = object : LoginListener {
        override fun onLoginSuccess(result: LineLoginResult) {
            Log.e("我沒看到","我沒看到" $result")
            handleLoginResult(result)

        }

        override fun onLoginFailure(result: LineLoginResult?) {
            Log.e("我沒看到","我沒看到 $result")
            handleLoginResult(result ?: LineLoginResult.internalError("Unknown error"))
        }
    }

    AndroidView({ LoginButton(it) }, modifier = modifier) { loginButton ->
        // A delegate for delegating the login result to the internal login handler.
        val loginDelegate = LoginDelegate.Factory.create()

        loginButton.apply {
            setChannelId(channelId)
            setLoginDelegate(loginDelegate)
            addLoginListener(loginListener)
        }
    }
}

What did you do?

Just click login button do login 。

What did you expect?

Get result from LoginListener。

What happened actually?

LoginListener seem not be called , but it will call back from


override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
    // In order to receive and process the Activity Result to the `LineLoginButton`.
    handleLoginResult(resultCode, data)
}


## Your environment?

> Oppo Android 11 device

就這樣 謝拉