Skip to content

Working on iOS, native crash in Android #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
keithahern opened this issue Oct 9, 2018 · 14 comments
Closed

Working on iOS, native crash in Android #65

keithahern opened this issue Oct 9, 2018 · 14 comments

Comments

@keithahern
Copy link

keithahern commented Oct 9, 2018

I have a working iOS implementation but my android build crashes hard when a login is attempted.

exported project shows google-services.json is there.

Thanks,

E/native-googlesignin: configuration is null!?
E/SignInFragment: Request not configured! Failing authenticate
E/CRASH: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'samsung/dream2ltexx/dream2lte:8.0.0/R16NW/G955FXXU3CRGH:user/release-keys'
Revision: '10'
E/CRASH: pid: 15207, tid: 15627, name: UnityMain >>> com.secret.viewer2 <<<
r0 00000000 r1 d0d61b48 r2 f3b3a174 r3 d4fd27a8
r4 ccd1cc10 r5 d0d61f94 r6 00000000 r7 00000000
r8 c8651cd0 r9 00000000 sl d0d62064 fp d0d61b38
ip c1d0a583 sp d0d61b38 lr f3b3a184 pc c1d0a584 cpsr f3687c90
backtrace:
E/CRASH: #00 pc 00008584 /data/app/com.secret.viewer2-v-p87JezfbUGR35eKkp6Lw==/lib/arm/libnative-googlesignin.so (GoogleSignIn_Pending+1)
#1 pc 00002180 ( (wrapper managed-to-native) Google.Impl.GoogleSignInImpl:GoogleSignIn_Pending (System.Runtime.InteropServices.HandleRef) + 0x48 (0xf3b3a138 0xf3b3a1c0) [0xf2c7bee0 - Unity Root Domain]+8576)
#2 il ........ at (wrapper managed-to-native) Google.Impl.GoogleSignInImpl.GoogleSignIn_Pending (System.Runtime.InteropServices.HandleRef) <IL 0x0002d, 0xffffffff>

@keithahern
Copy link
Author

I have a habit of finding solutions after I post issues :-)

It was due to some bad refactoring to allow for staging and production values for the oauth ID, they were never properly assigned. Not sure how the iOS version worked though.

@nvtuan96
Copy link

I have a habit of finding solutions after I post issues :-)

It was due to some bad refactoring to allow for staging and production values for the oauth ID, they were never properly assigned. Not sure how the iOS version worked though.

Hi @keithahern , Could you explain to me how to resolve this problem on Android ?

@keithahern
Copy link
Author

Hi @nvtuan96

That's a while ago. The problem was in my code and the oauth-id, there is different behaviour for Android and iOS. It was a case of getting the right oauth ID which was tricky and IIRC involved Google cloud rather than Firebase. The wrong oauth ID generally failed with unhelpful errors or crashes.

From this page
https://console.cloud.google.com/apis/credentials?project=your-project-name-here

You need the following kinds of oauth ids
Web client (Auto-created for Google Sign-in) | Oct 12, 2018 | Web application

Here's a bit of our login code

stagingWebClientId and productionWebClientId are set to the values from the oath id above e.g. 18XXXXXXX-YYYYYYYYYYY.apps.googleusercontent.com

 /*
         * Uses google signin
         */
        void OnSignInFirebaseGoogleSignin()
        {
            if (GoogleSignIn.Configuration == null) {
                Debug.Log("AUTH Setting Google Default Configuration");
                GoogleSignIn.Configuration = new GoogleSignInConfiguration
                {
                    WebClientId = lifecycleManager.stagingModeToggle.isOn ? stagingWebClientId : productionWebClientId,
                    RequestIdToken = true
                };
            }

            Task<GoogleSignInUser> signIn;

             Debug.Log("AUTH Google Signing in, pop up should appear ");

                // this pops up the google signin.
                signIn = GoogleSignIn.DefaultInstance.SignIn();
            

@bhupiister
Copy link

@keithahern I am encountering a similar error, but in my case, I have implemented google sign in and Firebase email auth in my unity app.

  1. if I login into Google sign-in first and sign out, and then sign in with other firebase auth method and then again come back and try to sign in to google sign in. It works.
  2. if I login into firebase Email and password and logout, and then try to sign in with google plugin, it gives this error. The Google Sign-in button greys out and app crashes. I will post my script and error both below.

`#if UNITY_ANDROID || UNITY_IOS || UNITY_EDITOR
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Firebase;
using Firebase.Auth;
using Google;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using System.Text.RegularExpressions;
using System.Collections;

public class Authentication : MonoBehaviour
{
public string webClientId = "";
[SerializeField] private string sceneToJump;
[SerializeField] private string sceneToLoad;

public InputField emailInp;
public InputField passwordInp;
public InputField confirmPasswordInp;
public Text warningInfo;

FirebaseAuth auth;
FirebaseUser user;
PhoneAuthProvider provider;

private string phoneId;

private GoogleSignInConfiguration configuration;

public GameObject VerificationPanel;
public Text EmailConfirmationMessage;
public Button SendEmailButton;
public Button ResendEmailButton;
public GameObject emailVerifyDoneCheck;
public GameObject phoneVerifyDoneCheck;
public Text warningEmailVerify;

public InputField countryCodeInp;
public InputField phoneNumberInp;
public InputField OTPInp;
public Button sendOTPButton;
public Button submitOTPButton;
public Text warningPhoneVerify;

public Button VerificationDoneButton;


public const string MatchEmailPattern =
        @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
        + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
          + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
        + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";

private void Awake()
{

    Debug.Log("Authentication_Stage1");
    //CheckFirebaseDependencies();
    Debug.Log("Authentication_Stage2:  " + webClientId);
    Initialize();
    //configuration = new GoogleSignInConfiguration { WebClientId = webClientId, RequestEmail = true, RequestIdToken = true };

}

private void Initialize()
{
    Debug.Log("Authentication_Stage3");
    auth = FirebaseAuth.DefaultInstance;
    auth.StateChanged += AuthStateChanged;
    AuthStateChanged(this, null);

    //auth = FirebaseAuth.DefaultInstance;
    //auth.StateChanged += AuthStateChanged;
}

private void CheckFirebaseDependencies()
{
    //FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
    //{
    //    if (task.IsCompleted)
    //    {
    //        if (task.Result == DependencyStatus.Available)
    //            auth = FirebaseAuth.DefaultInstance;
    //            //auth.StateChanged += AuthStateChanged;
    //            //auth.IdTokenChanged += IdTokenChanged;
    //        else
    //            AddToInformation("Could not resolve all Firebase dependencies: " + task.Result.ToString());
    //    }
    //    else
    //    {
    //        AddToInformation("Dependency check was not completed. Error : " + task.Exception.Message);
    //    }
    //});
}

public void SignInWithGoogle() { OnSignIn(); }
public void SignOutFromGoogle() { OnSignOut(); }

public void SignInWithEmailAndPassword()
{
    var email = emailInp.text;
    var password = passwordInp.text;
    bool emailRegExp = IsEmail(email);
    if (emailRegExp)
    {
        if (password.Length > 6)
        {
            SignInWithEmailAndPassword(email, password);
            warningInfo.text = "Everthing is perfect to SingIn";
        }
        else
        {
            warningInfo.text = "Password should have atleast 6 characters!";
        }
    }
    else
    {
        warningInfo.text = "Please enter valid Email address!";
    }

}
public void SignUpWithEmailAndPassword()
{
    var email = emailInp.text;
    var password = passwordInp.text;
    var confirmPassword = confirmPasswordInp.text;
    bool emailRegExp = IsEmail(email);
    if (emailRegExp)
    {
        if (password.Length > 6)
        {
            if (password == confirmPassword)
            {
                SignUpWithEmailAndPassword(email, password);
                warningInfo.text = "Everthing is perfect to SignUp";
            }
            else
            {
                warningInfo.text = "Password and confirm password does not match!";
            }

        }
        else
        {
            warningInfo.text = "Password should have atleast 6 characters!";
        }
    }
    else
    {
        warningInfo.text = "Please enter valid Email address!";
    }
}

public static bool IsEmail(string email)
{
    if (email != null) return Regex.IsMatch(email, MatchEmailPattern);
    else return false;
}
public void HidePasswordText()
{
    passwordInp.contentType = InputField.ContentType.Password;
    confirmPasswordInp.contentType = InputField.ContentType.Password;
    passwordInp.ForceLabelUpdate();
    confirmPasswordInp.ForceLabelUpdate();
}
public void ShowPasswordText()
{
    passwordInp.contentType = InputField.ContentType.Standard;
    confirmPasswordInp.contentType = InputField.ContentType.Standard;
    passwordInp.ForceLabelUpdate();
    confirmPasswordInp.ForceLabelUpdate();

}

private void OnSignIn()
{
    auth = FirebaseAuth.DefaultInstance;
    auth.StateChanged += AuthStateChanged;

    GoogleSignIn.Configuration = new GoogleSignInConfiguration { WebClientId = webClientId, RequestEmail = true, RequestIdToken = true };
    //GoogleSignIn.Configuration.UseGameSignIn = false;
    //GoogleSignIn.Configuration.RequestIdToken = true;
    Debug.Log("Calling SignIn");
    Debug.Log("Authentication_Stage4");
    //GoogleSignIn.Configuration.ForceTokenRefresh = true;
    Debug.Log("Authentication_Stage4.1");
    GoogleSignIn.DefaultInstance.SignIn().ContinueWith(OnAuthenticationFinished);
    Debug.Log("Authentication_Stage4.2");

}

private void OnSignOut()
{
    Debug.Log("Calling SignOut");
    GoogleSignIn.DefaultInstance.SignOut();
    FirebaseAuth.DefaultInstance.SignOut();
}

public void OnDisconnect()
{
    Debug.Log("Calling Disconnect");
    GoogleSignIn.DefaultInstance.Disconnect();
}

internal void OnAuthenticationFinished(Task<GoogleSignInUser> task)
{
    Debug.Log("Authentication_Stage5");

    if (task.IsFaulted)
    {
        using (IEnumerator<Exception> enumerator = task.Exception.InnerExceptions.GetEnumerator())
        {
            if (enumerator.MoveNext())
            {
                Debug.Log("Authentication_Stage5.1");
                GoogleSignIn.SignInException error = (GoogleSignIn.SignInException)enumerator.Current;
                Debug.Log("Got Error: " + error.Status + " " + error.Message);
                Debug.Log("Authentication_Stage5.2");
            }
            else
            {
                Debug.Log("Got Unexpected Exception?!?" + task.Exception);
                Debug.Log("Authentication_Stage6");
            }
        }
    }
    else if (task.IsCanceled)
    {
        Debug.Log("Canceled");
    }
    else
    {
        Debug.Log("Welcome: " + task.Result.DisplayName + "!");
        Debug.Log("Email = " + task.Result.Email);
        //AddToInformation("Google ID Token = " + task.Result.IdToken);
        Debug.Log("Authentication_Stage7");
        SignInWithGoogleOnFirebase(task.Result.IdToken);
    }
}

private void SignInWithEmailAndPassword(string email, string password)
{
    auth.StateChanged += AuthStateChanged;
    auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => {
        if (task.IsCanceled)
        {
            Debug.LogError("SignInWithEmailAndPasswordAsync was canceled.");
            return;
        }
        if (task.IsFaulted)
        {
            Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception);
            return;
        }

        user = task.Result;

        Debug.LogFormat("User signed in successfully: {0} ({1}) ({2})",
            user.DisplayName, user.UserId, user.IsEmailVerified);
        //CheckUser();
    });
}

private void SignUpWithEmailAndPassword(string email, string password)
{
    auth.StateChanged += AuthStateChanged;
    auth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task => {
        if (task.IsCanceled)
        {
            Debug.LogError("CreateUserWithEmailAndPasswordAsync was canceled.");
            return;
        }
        if (task.IsFaulted)
        {
            Debug.LogError("CreateUserWithEmailAndPasswordAsync encountered an error: " + task.Exception);
            return;
        }

        // Firebase user has been created.
        user = task.Result;
        Debug.LogFormat("Firebase user created successfully: {0} ({1})",
            user.DisplayName, user.UserId);
        //CheckUser();

    });
}

private void SignInWithGoogleOnFirebase(string idToken)
{
    Credential credential = GoogleAuthProvider.GetCredential(idToken, null);

    auth.StateChanged += AuthStateChanged;
    Debug.Log("Authentication_Stage8");
    auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
    {
        AggregateException ex = task.Exception;
        if (ex != null)
        {
            if (ex.InnerExceptions[0] is FirebaseException inner && (inner.ErrorCode != 0))
            {
                Debug.Log("Authentication_Stage9");
                Debug.Log("\nError code = " + inner.ErrorCode + " Message = " + inner.Message);
            }
        }
        else
        {
            Debug.Log("Sign in Successful.");
            FirebaseUser newUser = task.Result;
            Debug.Log("Authentication_Stage10");
            Debug.LogFormat("User signed in successfully: {0} ({1}) Email verified?:{2}", newUser.DisplayName, newUser.UserId, newUser.IsEmailVerified);



        }
    });
}



public void SkipToLoggedIn()
{

    SceneManager.LoadScene(sceneToJump);

}
private void AuthStateChanged(object sender, EventArgs eventArgs)
{
    if (auth.CurrentUser != user)
    {
        bool signedIn = user != auth.CurrentUser && auth.CurrentUser != null;
        if (!signedIn && user != null)
        {
            Debug.Log("Signed out " + user.UserId);
        }
        user = auth.CurrentUser;
        if (signedIn)
        {
            Debug.Log("Checking Authetication in AuthStateChanged");

            Debug.Log("Signed in " + user.UserId);

            CheckUser();
        }
    }


}


void OnDestroy()
{
    FirebaseAuth.DefaultInstance.StateChanged -= AuthStateChanged;

    if (auth != null)
    {
        auth.StateChanged -= AuthStateChanged;
        auth = null;
    }
}

}
`
Error:
05-04 04:58:02.293: I/Unity(8821):
05-04 04:58:02.293: I/Unity(8821): (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
05-04 04:58:02.295: E/native-googlesignin(8821): configuration is null!?
05-04 04:58:02.296: E/SignInFragment(8821): Request not configured! Failing authenticate
05-04 04:58:02.301: E/CRASH(8821): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000

@jonathanahern
Copy link

Hi @bhupiister. You had the same problem I'm having. Did you ever resolve it and how?

@bhupiister
Copy link

Hi @bhupiister. You had the same problem I'm having. Did you ever resolve it and how?

Yes, I did but will need to find it. Give me one day's time and ill post the script.

@jonathanahern
Copy link

Hi @bhupiister. You had the same problem I'm having. Did you ever resolve it and how?

Yes, I did but will need to find it. Give me one day's time and ill post the script.

Thank you. I'd really appreciate it!

@jonathanahern
Copy link

Sorry to bother @bhupiister. Were you able to find it? Thanks.

@bhupiister
Copy link

@jonathanahern
here is the link to my script, see if you missed something from it.
https://gist.github.com/bhupiister/673c259613c8cc060dcc54a88042cdaf

@bhupiister
Copy link

@jonathanahern
I almost forgot that i made a gist for this particular problem.Please look carefully at the two links below, i hope you will find the solution. Ignore the previous reply, but if you want to use phone authentication and other features, you can look at it.
https://gist.github.com/bhupiister/c329c33ae6a217f34193728d93a3e7d9
https://gist.github.com/bhupiister/72f894df9ff6ad03ac7dfa0ebfcb8d20

@jonathanahern
Copy link

Thanks for getting back to me @bhupiister

Those gist links come up as blank links for me unfortunately. Do you have another way to share? Or is that Apple Sign in repo you have a working version? I could check that out.

Thanks for your help. I appreciate it!

@bhupiister
Copy link

`

namespace Google.Impl {
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;

internal class GoogleSignInImpl : BaseObject, ISignInImpl {

#if UNITY_ANDROID
private const string DllName = "native-googlesignin";
#else
private const string DllName = "__Internal";
#endif

    internal GoogleSignInImpl(GoogleSignInConfiguration configuration)
            : base(GoogleSignIn_Create(GetPlayerActivity()))
    {
        Configure(configuration);
    }

    public void Configure(GoogleSignInConfiguration configuration)
    {
        if (configuration != null)
        {
            List<string> scopes = new List<string>();
            if (configuration.AdditionalScopes != null)
            {
                scopes.AddRange(configuration.AdditionalScopes);
            }
            GoogleSignIn_Configure(SelfPtr(), configuration.UseGameSignIn,
                            configuration.WebClientId,
                            configuration.RequestAuthCode,
                            configuration.ForceTokenRefresh,
                            configuration.RequestEmail,
                            configuration.RequestIdToken,
                            configuration.HidePopups,
                            scopes.ToArray(),
                            scopes.Count,
                            configuration.AccountName);
        }
    }

    /// <summary>Enables/Disables verbose logging to help troubleshooting</summary>
    public void EnableDebugLogging(bool flag) {
    GoogleSignIn_EnableDebugLogging(SelfPtr(), flag);
}

/// <summary>
/// Starts the authentication process.
/// </summary>
/// <remarks>
/// The authenication process is started and may display account picker
/// popups and consent prompts based on the state of authentication and
/// the requested elements.
/// </remarks>
public Future<GoogleSignInUser> SignIn() {
  IntPtr nativeFuture = GoogleSignIn_SignIn(SelfPtr());
  return new Future<GoogleSignInUser>(new NativeFuture(nativeFuture));
}

/// <summary>
/// Starts the authentication process.
/// </summary>
/// <remarks>
/// The authenication process is started and may display account picker
/// popups and consent prompts based on the state of authentication and
/// the requested elements.
/// </remarks>
public Future<GoogleSignInUser> SignInSilently() {
  IntPtr nativeFuture = GoogleSignIn_SignInSilently(SelfPtr());
  return new Future<GoogleSignInUser>(new NativeFuture(nativeFuture));
}

/// <summary>
/// Signs out the User.
/// </summary>
public void SignOut() {
  GoogleSignIn_Signout(SelfPtr());
}

/// <summary>
/// Disconnects the user from the application and revokes all consent.
/// </summary>
public void Disconnect() {
  GoogleSignIn_Disconnect(SelfPtr());
}

/// <summary>
/// Creates an instance of the native Google Sign-In implementation.
/// </summary>
/// <remarks>
///  For Android this must be the JNI raw object for the parentActivity.
///  For iOS it is ignored.
/// </remarks>
/// <returns>The pointer to the instance.</returns>
/// <param name="data">Data used in creating the instance.</param>
[DllImport(DllName)]
static extern IntPtr GoogleSignIn_Create(IntPtr data);

[DllImport(DllName)]
static extern void GoogleSignIn_EnableDebugLogging(HandleRef self, bool flag);

[DllImport(DllName)]
static extern bool GoogleSignIn_Configure(HandleRef self,
  bool useGameSignIn, string webClientId,
  bool requestAuthCode, bool forceTokenRefresh, bool requestEmail,
  bool requestIdToken, bool hidePopups, string[] additionalScopes,
  int scopeCount, string accountName);

[DllImport(DllName)]
static extern IntPtr GoogleSignIn_SignIn(HandleRef self);

[DllImport(DllName)]
static extern IntPtr GoogleSignIn_SignInSilently(HandleRef self);

[DllImport(DllName)]
static extern void GoogleSignIn_Signout(HandleRef self);

[DllImport(DllName)]
static extern void GoogleSignIn_Disconnect(HandleRef self);

[DllImport(DllName)]
internal static extern void GoogleSignIn_DisposeFuture(HandleRef self);

[DllImport(DllName)]
internal static extern bool GoogleSignIn_Pending(HandleRef self);

[DllImport(DllName)]
internal static extern IntPtr GoogleSignIn_Result(HandleRef self);

[DllImport(DllName)]
internal static extern int GoogleSignIn_Status(HandleRef self);

[DllImport(DllName)]
internal static extern UIntPtr GoogleSignIn_GetServerAuthCode(
  HandleRef self, [In, Out] byte[] bytes, UIntPtr len);

[DllImport(DllName)]
internal static extern UIntPtr GoogleSignIn_GetDisplayName(HandleRef self,
  [In, Out] byte[] bytes, UIntPtr len);

[DllImport(DllName)]
internal static extern UIntPtr GoogleSignIn_GetEmail(HandleRef self,
  [In, Out] byte[] bytes, UIntPtr len);

[DllImport(DllName)]
internal static extern UIntPtr GoogleSignIn_GetFamilyName(HandleRef self,
  [In, Out] byte[] bytes, UIntPtr len);

[DllImport(DllName)]
internal static extern UIntPtr GoogleSignIn_GetGivenName(HandleRef self,
  [In, Out] byte[] bytes, UIntPtr len);

[DllImport(DllName)]
internal static extern UIntPtr GoogleSignIn_GetIdToken(HandleRef self,
  [In, Out] byte[] bytes, UIntPtr len);

[DllImport(DllName)]
internal static extern UIntPtr GoogleSignIn_GetImageUrl(HandleRef self,
  [In, Out] byte[] bytes, UIntPtr len);

[DllImport(DllName)]
internal static extern UIntPtr GoogleSignIn_GetUserId(HandleRef self,
  [In, Out] byte[] bytes, UIntPtr len);

// Gets the Unity player activity.
// For iOS, this returns Zero.
private static IntPtr GetPlayerActivity() {

#if UNITY_ANDROID && !UNITY_EDITOR
UnityEngine.AndroidJavaClass jc = new UnityEngine.AndroidJavaClass(
"com.unity3d.player.UnityPlayer");
return jc.GetStatic<UnityEngine.AndroidJavaObject>("currentActivity")
.GetRawObject();
#else
return IntPtr.Zero;
#endif
}
}
}

`

@bhupiister
Copy link

`
namespace Google {
using System;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using Google.Impl;
using UnityEngine;

public class GoogleSignIn {

#if !UNITY_ANDROID && !UNITY_IOS
static GoogleSignIn() {
Debug.LogError("This platform is not supported");
}
#endif

private static GoogleSignIn theInstance = null;
private static GoogleSignInConfiguration theConfiguration = null;
private ISignInImpl impl;

    ///<summary> The configuration settings for Google Sign-in.</summary>
    ///<remarks> The configuration should be set before calling the sign-in
    /// methods.  Once the configuration is set it cannot be changed.
    ///</remarks>
    public static GoogleSignInConfiguration Configuration
    {
        set
        {
            // Can set the configuration until the singleton is created.
            if (theInstance == null || theConfiguration == value || theConfiguration == null)
            {
                if (theInstance != null && theConfiguration == null)
                {
                    //From sign out, Instance stays non-null but theConfiguration is null.
                    //Needs configuration refresh.
                    theInstance.impl.Configure(value);
                }
                theConfiguration = value;
            }
            else
            {
                throw new SignInException(GoogleSignInStatusCode.DeveloperError,
                    "DefaultInstance already created. " +
                    " Cannot change configuration after creation.");
            }
        }

        get
        {
            return theConfiguration;
        }
    }

    /// <summary>
    /// Singleton instance of this class.
    /// </summary>
    /// <value>The instance.</value>
    public static GoogleSignIn DefaultInstance
    {
        get
        {
            Debug.Log("GSIn 1.0");
            if (theInstance == null)
            {

#if UNITY_ANDROID || UNITY_IOS
theInstance = new GoogleSignIn(new GoogleSignInImpl(Configuration));
#else
theInstance = new GoogleSignIn(null);
throw new SignInException(
GoogleSignInStatusCode.DeveloperError,
"This platform is not supported by GoogleSignIn");
#endif
}
Debug.Log("GSIn 1.1");
return theInstance;
}
}

    internal GoogleSignIn(GoogleSignInImpl impl) {
  this.impl = impl;
}

public void EnableDebugLogging(bool flag) {
        impl.EnableDebugLogging(flag);
}

    /// <summary>Starts the authentication process.</summary>
    /// <remarks>
    /// The authenication process is started and may display account picker
    /// popups and consent prompts based on the state of authentication and
    /// the requested elements.
    /// </remarks>
    public Task<GoogleSignInUser> SignIn()
    {
        Debug.Log("GSInUser 1.0");
        var tcs = new TaskCompletionSource<GoogleSignInUser>();
        SignInHelperObject.Instance.StartCoroutine(
          impl.SignIn().WaitForResult(tcs));
        Debug.Log("GSInUser 1.1");
        return tcs.Task;
    }

    /// <summary>Starts the silent authentication process.</summary>
    /// <remarks>
    /// The authenication process is started and will attempt to sign in without
    /// displaying any UI.  If this cannot be done, the developer should call
    /// SignIn().
    /// </remarks>
    public Task<GoogleSignInUser> SignInSilently() {
  var tcs = new TaskCompletionSource<GoogleSignInUser>();
  SignInHelperObject.Instance.StartCoroutine(
      impl.SignInSilently().WaitForResult(tcs));
  return tcs.Task;
}

/// <summary>
/// Signs out the User.
/// </summary>
/// <remarks>Future sign-in attempts will require the user to select the
/// account to use when signing in.
/// </remarks>
public void SignOut() {
  theConfiguration = null;
  impl.SignOut();
}

/// <summary>
/// Disconnect this instance.
/// </summary>
/// <remarks>When the user is disconnected, it revokes all access that may
/// have been granted to this application.  This includes any server side
/// access tokens derived from server auth codes.  As a result, future
/// sign-in attempts will require the user to re-consent to the requested
/// scopes.
/// </remarks>
public void Disconnect() {
  impl.Disconnect();
}

/// <summary>
/// Sign in exception.  This is a checked exception for handling specific
/// errors during the sign-in process.
/// </summary>
[Serializable]
public class SignInException : Exception {
  internal SignInException(GoogleSignInStatusCode status) {
    Status = status;
  }

  public SignInException(GoogleSignInStatusCode status, string message) :
      base(message) {
    Status = status;
  }

  public SignInException(GoogleSignInStatusCode status, string message,
      Exception innerException) : base(message, innerException) {
    Status = status;
  }

  protected SignInException(GoogleSignInStatusCode status,
                            SerializationInfo info,
                            StreamingContext context) :
      base(info, context) {
    Status = status;
  }

  public GoogleSignInStatusCode Status {
    get;
    internal set;
  }
}

}

internal interface ISignInImpl {
Future SignIn();
Future SignInSilently();
void EnableDebugLogging(bool flag);
void SignOut();
void Disconnect();
void Configure(GoogleSignInConfiguration configuration);
}
} // namespace Google
`

@bhupiister
Copy link

@jonathanahern
I have pasted both the script here itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants