Is there any example code on how to use the google sign in button in jetpack compose? Or do I need to wrap the google sign in button in an android view?
Jason Inbody
08/21/2021, 1:57 AM
Copy code
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build()
val mGoogleSignInClient = GoogleSignIn.getClient(user.context, gso)
val signInIntent = mGoogleSignInClient.signInIntent
val googleSignInLauncher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.StartActivityForResult()
){ result: ActivityResult ->
if (result.resultCode == Activity.RESULT_OK) {
// you will get result here in result.data
val task: Task<GoogleSignInAccount> = GoogleSignIn.getSignedInAccountFromIntent(result.data)
print("hello")
}else{
user.openErrorDialog("Google Sign In Failure", "Failed to sign in with Google")
}
}