Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google SignIn not working for iOS 10

I have integrated the GoogleSinIn API in my project with Swift 4.0. It is working on iOS 11.0 but when I'm testing the same on iOS 10.0 it is opening the Google login page on the Safari browser or the device and after signing successfully it is opening the Google search page.

  1. When I click the GoogleSignIn button shown below it opens the browser shown in next image.

  2. Then I fill up the credentials.

  3. After the successful signed in, It redirects to the Google page instead of the application page.

like image 877
Sahil Dhiman Avatar asked Oct 10 '17 10:10

Sahil Dhiman


People also ask

Why can't I log into Google on my Iphone?

Update your device to the latest version of iOS or iPadOS. You can update your device wirelessly by going to Settings > General > Software Update and if there is an update, follow the onscreen instructions to update your device. Clear the history, cache and cookies to see if this fixes your problem.


2 Answers

You have to implement this delegate function in your AppDelegate.

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
     return GIDSignIn.sharedInstance().handle(url as URL!, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])
}
like image 54
sRoy Avatar answered Oct 10 '22 04:10

sRoy


check your GIDSignInUIDelegate, don't forget

func sign(_ signIn: GIDSignIn!, present viewController: UIViewController!) {
    self.present(viewController, animated: true, completion: nil)
}

func sign(_ signIn: GIDSignIn!, dismiss viewController: UIViewController!) {
    self.dismiss(animated: true, completion: nil)
}
like image 26
Yifan Avatar answered Oct 10 '22 05:10

Yifan