Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIDSignIn white screen on iOS 9

I implemented Google sign in and everything works on iOS 8. But when I call this line on iOS 9:

GIDSignIn.sharedInstance().signIn()

I'm able to log in the first time. But if I cancel, the next time I try to log in it shows a white screen where the normal user approval web view would be.

This even happens when I delete the app and reinstall it, meaning that something might be getting cached at the OS level.

The only solution is to reopen the iOS Simulator or restart my iPhone.

I've tried all these answers with no luck. I've also tried GIDSignIn.sharedInstance().signIn().allowsSignInWithWebView = true hoping that authorizing through Safari might work, but Safari never opens. My Podfile has pod 'Google/SignIn' so I don't think it's a version issue.

I'm at a loss at this point, because this goes beyond the scope of my app, and all I can think of is to deconstruct a working example app and compare its settings with my app line by line.

Does someone have a link to a working example app?

like image 259
Zack Morris Avatar asked Feb 13 '16 03:02

Zack Morris


3 Answers

So, I had exactly the same issue as you. It spent me hrs to try out everything. I finally found a solution, which might not be 100% correct, but it works for me and fixed the problem.

This is what I did in my project. First, I implemented the three GIDSignInUIDelegate functions myself, which is conflict to the official document because my GIDSignInUIDelegate is subclass to the UIViewController. But I am using my custom signing button, and it didn't work when I followed the google official document. So I tried out everything and found it works.

After you implemented the delegate function, there are two major things need to do.

  1. In the following function, set viewController.view.layoutIfNeeded()

     func sign(_ signIn: GIDSignIn!, present viewController: UIViewController!) {
         //This line does the trick to fix signin web not showing issue
         viewController.view.layoutIfNeeded()
    
         self.present(viewController, animated: true, completion: nil)
      }
    
  2. Don't set up this delegate in the ViewDidLoad()

    GIDSignIn.sharedInstance().uiDelegate = self
    

Instead, set them up in the button action. Otherwise, it somehow keeps showing delegate

Hope it will help your problem.

like image 178
Tim Lin Avatar answered Sep 22 '22 11:09

Tim Lin


I am also facing same issue. In fact in one Viewcontroller it is working for me and another viewcontroller it is not working.

It works for me if I call [[GIDSignIn sharedInstance] signIn] inside some Button Action method and not in. But if I call it inside viewDidLoad I get white screen.

I found another workaround but I am not going by this as I think it is not reliable

[self performSelector:@selector(LogActionPresed:) withObject:self afterDelay:3.5];

Where LogActionPresed is method which internally calls [[GIDSignIn sharedInstance] signIn]

Another Working Solution is to call this method inside viewDidAppear

- (void) viewDidAppear:(BOOL)animated {
    [self LogActionPresed:self];
}
like image 44
Ashish Avatar answered Sep 22 '22 11:09

Ashish


On iOS 10, I'm observing that it works if the presenting view controller is in the stack of a UINavigationController. The web view remains empty and white if the presenting view controller is not in such a stack.

like image 33
Etienne Avatar answered Sep 20 '22 11:09

Etienne