google-signin-unity
google-signin-unity copied to clipboard
Uncaught exception: NSInvalidArgumentException: presentingViewController must be set.
Build for iOS. Second authentication via Google account leads to application crash. Steps:
- I first log into the client with Google account;
- do logging out;
- log in again with Google;
- close client (remove from memory);
- launch the client again;
- do logging out;
- try login in via google again;
- get a crash of the system;
I see an error in the logs: Uncaught exception: NSInvalidArgumentException: presentingViewController must be set.
The same system crash (same exception) can be obtained if:
- I first log into the client with Google account;
- Hide application;
- go to the system settings and change system language;
- launch application again;
- logging out from Google accout;
- try sign in via google again;
- get a crash of the system;
If restart the application after that, then everything will be fine.
I had the same problem quite a number of times. Did not find out yet when and why this happens. This package is so buggy...
I had the same problem quite a number of times. Did not find out yet when and why this happens. This package is so buggy...
hi,guys. did you find any solution ?
I just bought the commercial Google Signin package in the Unity Asset store, there's currently a sale going on. The developer confirmed that he will maintain it for the foreseeable future; and should he ever drop support, he would post the source code on Github. I don't trust the "official" Google package anymore.
I found the solution. first of all you have to check GoogleSignIn.Configuration is null or not when you call GoogleSignIn.DefaultInstance.SignIn() or GoogleSignIn.DefaultInstance.SignOut(). If GoogleSignIn.Configuration is null you have to define it before you call GoogleSignIn.DefaultInstance.... ; Because GoogleSignIn.DefaultInstance returns you an instance and if it is null it is instantiated with confugiration again. So you have to check always your configuration. I implemented a method to initialize my configuration like that :
private void InitializeConfiguration()
{
if (GoogleSignIn.Configuration == null)
{
configuration = new GoogleSignInConfiguration
{
WebClientId = webClientId,
RequestIdToken = true
};
GoogleSignIn.Configuration = configuration;
GoogleSignIn.Configuration.UseGameSignIn = false;
GoogleSignIn.Configuration.RequestIdToken = true;
GoogleSignIn.Configuration.RequestAuthCode = true;
GoogleSignIn.Configuration.RequestEmail = true;
GoogleSignIn.Configuration.RequestProfile = true;
}
} Then I call it on my methods before calling GoogleSignIn.DefaultInstance... For example :
InitializeConfiguration();
GoogleSignIn.DefaultInstance.SignIn().ContinueWith(
OnAuthenticationFinished, TaskContinuationOptions.ExecuteSynchronously);
or
InitializeConfiguration();
GoogleSignIn.DefaultInstance.SignOut();
So it works on my situation without any errors and bugs. Have a nice day guys :)
I found the solution. first of all you have to check GoogleSignIn.Configuration is null or not when you call GoogleSignIn.DefaultInstance.SignIn() or GoogleSignIn.DefaultInstance.SignOut(). If GoogleSignIn.Configuration is null you have to define it before you call GoogleSignIn.DefaultInstance.... ; Because GoogleSignIn.DefaultInstance returns you an instance and if it is null it is instantiated with confugiration again. So you have to check always your configuration.
This is a bit different. I also had this problem initially. This is a missing configuration issue. And that's how I solved it. But the described problem is different and have different exception.
It's still relevant for us, have you found a solution? Firebase SDK 6.15.2
Let me share what helped me with the current issue:
I've changed GoogleSignIn.mm file, specificly method GoogleSignIn_SignIn – I've put the next line before [[GIDSignIn sharedInstance] signIn];
[GIDSignIn sharedInstance].presentingViewController = UnityGetGLViewController();

Your fix also worked for me. I created a PR for it, linked just above.