Emad Younan

Emad Younan

  • 1.9k
  • 36
  • 353

google sign in issue is it related to play store or not?

Mar 29 2020 7:26 PM
this is my code 
 when i debug it at visual stuido it works good but when i archive it to install at my phone to test it not working
is it related with play store i have to put it at play store to can access the google sign in? 
 
gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken("Token.apps.googleusercontent.com") .RequestEmail() .Build(); googleApiClient = new GoogleApiClient.Builder(this) .EnableAutoManage(this, this) .AddApi(Auth.GOOGLE_SIGN_IN_API, gso).Build(); protected override void OnStart()
{ base.OnStart(); var opr = Auth.GoogleSignInApi.SilentSignIn(googleApiClient);
if (opr.IsDone) { // If the user's cached credentials are valid, the OptionalPendingResult will be "done" // and the GoogleSignInResult will be available instantly. var result = opr.Get() as GoogleSignInResult; HandleSignInResult(result); } }
protected override void OnResume()
{ base.OnResume(); } public void HandleSignInResult(GoogleSignInResult result)
{ if (result.IsSuccess) { // Signed in successfully, show authenticated UI. var acct = result.SignInAccount; } else { // Signed out, show unauthenticated UI. } }
protected override void OnStop()
{ base.OnStop(); if (googleApiClient.IsConnected) { googleApiClient.Disconnect(); } }
public void OnConnected(Bundle connectionHint) { //throw new NotImplementedException(); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { try { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == sign_id) { var result = Auth.GoogleSignInApi.GetSignInResultFromIntent(data); HandlessSignIn(result); } } catch (Exception ex) { Toast.MakeText(this, ex.Message.ToString(), ToastLength.Long).Show(); } //base.OnActivityResult(requestCode, resultCode, data); }
private void HandlessSignIn(GoogleSignInResult result) { try { if (result.IsSuccess) { var accountDetails = result.SignInAccount; prg.Visibility = ViewStates.Invisible; } } } catch (Exception ex) { Toast.MakeText(this, ex.Message.ToString(), ToastLength.Long).Show(); } }
private void Siggoogle_Click(object sender, EventArgs e) { prg.Visibility = ViewStates.Visible; var intent = Auth.GoogleSignInApi.GetSignInIntent(googleApiClient); StartActivityForResult(intent, sign_id); } 
 

Brought to you by:

Answers (2)