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

errorCode='NOT_DEFINED #160

Open RubyJSeo opened 6 months ago

RubyJSeo commented 6 months ago

I'm not sure the reason for this error:

LineLoginResult{responseCode=CANCEL, nonce='null', lineProfile=null, lineIdToken=null, friendshipStatusChanged=null, lineCredential=null, errorData=LineApiError{httpResponseCode=-1, message='', errorCode='NOT_DEFINED'}}

`class TestActivityForLine : AppUpdateActivity() { private lateinit var binding: ActivityTestForLineBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityTestForLineBinding.inflate(layoutInflater) setContentView(binding.root)

    binding.button.setOnClickListener {
        try {
            val loginIntent = LineLoginApi.getLoginIntent(
                this@TestActivityForLine,
                LINE_CHANNEL_ID,
                LineAuthenticationParams.Builder()
                    .scopes(listOf(Scope.PROFILE))
                    .build()
            )
            startActivityForResult(loginIntent, REQUEST_CODE_LINE_LOGIN)
        } catch (e: Exception) {
            Logger.e("line login error: ${e.message}")
        }
    }
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)

    if (requestCode == LoginModule.REQUEST_CODE_LINE_LOGIN) {
        val result = LineLoginApi.getLoginResultFromIntent(data)
        Logger.e("line result: ${result}")
        Logger.e("line reponseCode: ${result.responseCode}")
        Logger.e("line resultCode: ${resultCode}")
        when (result.responseCode) {
            LineApiResponseCode.SUCCESS -> {
                // Login successful
                val transitionIntent = Intent(
                    this,
                    LauncherActivity::class.java
                )
                transitionIntent.putExtra("line_profile", result.lineProfile)
                transitionIntent.putExtra("line_credential", result.lineCredential)
                startActivity(transitionIntent)

            }
            LineApiResponseCode.CANCEL -> CustomSnackbar.error(this, result.errorData.toString(), Snackbar.LENGTH_LONG)
            else -> {
                CustomSnackbar.error(this, result.errorData.toString(), Snackbar.LENGTH_LONG)
            }
        }
    }
}

companion object {
    const val REQUEST_CODE_LINE_LOGIN = 1
    private const val LINE_CHANNEL_ID = "mychannelID"
}

}`