Google sign in not redirect to application after allow

I’m using this tutorial to implement Sign in with google in app.

  1. I installed GoogleSignIn via cocoapods. pod 'GoogleSignIn', '~> 2.4.0'
  2. Added GSignIn-Bridging-Header.h with #import <GoogleSignIn/GoogleSignIn.h> inside.
  3. Create url types: enter image description here

  4. Using Google+ iOS API how to get logged in user's profile details?
  5. Login with google plus in ios on
  6. Using google plus API is it possible to fetch gmail contacts
  7. Not automatically login to Google+ using UIWebView (iOS)?
  8. iOS Google+ Safari cannot open page because address is invalid
  9. Image Sharing Using Google Plus in ios
  10. Create a view with GIDSignInButton class

  11. Added code:

    class ViewController: UIViewController, GIDSignInDelegate,    GIDSignInUIDelegate {
    override func viewDidLoad() {
        GIDSignIn.sharedInstance().delegate = self
        GIDSignIn.sharedInstance().uiDelegate = self
        GIDSignIn.sharedInstance().clientID = "KEY" 
     func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {
    if let err = error {
    else {
       self.performSegueWithIdentifier("idSegueContent", sender: self)
    func signIn(signIn: GIDSignIn!, didDisconnectWithUser user: GIDGoogleUser!, withError error: NSError!) {
  12. But when i click allow

enter image description here

It redirects me to, not to app.

3 Solutions Collect From Internet About “Google sign in not redirect to application after allow”

In the AppDelegate, You need to add the Implementation of

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool
    return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)

Google sends back information through URL, the method above captures this information and send back to the Application.

I finally fixed this after a day’s work. @ayman Ibrahim was basically, right, but I think that the answer is a bit broader. Different versions of Swift/Objective-C and the Google SDK, call different versions of the canOpenURL method in the AppDelegate. I’m not 100% certain about that, and would appreciate confirmation or correction. Here is the version of that method which worked for me. I am using Google’s SDK v. 4.0, targeting iOS 9.1, and using Swift 3.0:

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    let checkFB = FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
    let checkGoogle = GIDSignIn.sharedInstance().handle(url as URL!,sourceApplication: sourceApplication,annotation: annotation)
    return checkGoogle || checkFB

I am also using the FBSDK, so ignore that line.

I did found another answer for it. In my case, in AppDelegate I did implement 2 delegate methods

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options


- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation

The first is the delegate method and should not implement anymore, it was replaced by the the second method. But somehow I still use both and just add

return [[GIDSignIn sharedInstance] handleURL:url

in the second one and then somehow again, it just callback to the first method then it not navigate to my app anymore.

So I want to post my case for someone who may get this mistake to, it took me too long to find out