Thread
#compose
    j

    Jason Inbody

    1 year ago
    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?
    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")
        }
    }
    then launch with
    googleSignInLauncher.launch(googleSignInIntent)
    worked for me