Created
January 31, 2024 14:36
-
-
Save vincent-paing/016b7a24a13b0745472ebcf93fe1da73 to your computer and use it in GitHub Desktop.
Line login implementation with ActivityResultContract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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