Skip to content

Instantly share code, notes, and snippets.

@vincent-paing
Created January 31, 2024 14:36
Show Gist options
  • Save vincent-paing/016b7a24a13b0745472ebcf93fe1da73 to your computer and use it in GitHub Desktop.
Save vincent-paing/016b7a24a13b0745472ebcf93fe1da73 to your computer and use it in GitHub Desktop.
Line login implementation with ActivityResultContract
class LineLogin : ActivityResultContract<LineLogin.Input, LineLoginResult>() {
data class Input(
val channelId: String,
val params: LineAuthenticationParams,
val isBrowserLoginOnly: Boolean
)
override fun createIntent(context: Context, input: Input): Intent {
val (channelId, params, isBrowserLoginOnly) = input
return if (isBrowserLoginOnly) {
LineLoginApi.getLoginIntentWithoutLineAppAuth(context, channelId, params)
} else {
LineLoginApi.getLoginIntent(context, channelId, params)
}
}
override fun parseResult(resultCode: Int, intent: Intent?): LineLoginResult {
return LineLoginApi.getLoginResultFromIntent(intent)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment