0

I am using Xcode 7.2, testing on iOS 9.2 and using pod 'Google/SignIn'

After login success and allowing the permission its redirect to the google.co.in page instead of close the screen and calling their delgates. The same is working fine in OS 7.0 and 8.0. Below is the code used for login.

GIDSignIn*sigNIn=[GIDSignIn sharedInstance];
[sigNIn setDelegate:self];
[sigNIn setUiDelegate:self];
sigNIn.shouldFetchBasicProfile = YES;
sigNIn.allowsSignInWithBrowser = NO;
sigNIn.allowsSignInWithWebView = YES;
sigNIn.scopes = @[@"https://www.googleapis.com/auth/plus.login",@"https://www.googleapis.com/auth/userinfo.email",@"https://www.googleapis.com/auth/userinfo.profile"];
sigNIn.clientID =@"77904325793-iqdungs3ugddrf7h767pgagviokfi4cg.apps.googleusercontent.com";
[sigNIn signIn];



 - (BOOL)application:(UIApplication *)app
        openURL:(NSURL *)url
        options:(NSDictionary *)options {
return [[GIDSignIn sharedInstance] handleURL:url
                           sourceApplication:options[UIApplicationLaunchOptionsSourceApplicationKey]
                                  annotation:options[UIApplicationLaunchOptionsAnnotationKey]];


}

After login it redirect to google.co.in instead of close the screen.

enter image description here

Chandan Kumar Jha
  • 325
  • 2
  • 4
  • 18
  • Have you set URL Scheme in URL Types of Info file in your project? – Jigar Tarsariya Apr 08 '16 at 05:11
  • yes CFBundleURLSchemes com.googleusercontent.apps.7790433-iqdungs3ugddrf7h767pgagfi4cg – Chandan Kumar Jha Apr 08 '16 at 05:15
  • [check this one may solve your issue](http://stackoverflow.com/questions/31506865/google-sign-in-crashes-on-ios-9-attempting-to-call-canopenurl) – Harshad Apr 08 '16 at 05:30
  • My login is working fine only issue its redirect to google.co.in instead of dismiss the screen. Also after review the url and adding the schemes not working. The same issue i am facing for Facebook also in OS 9 LSApplicationQueriesSchemes com-google-gidconsent-google com-google-gidconsent-youtube com-google-gidconsent – Chandan Kumar Jha Apr 08 '16 at 06:03

1 Answers1

2

I guess, it is because the openUrl function has been changed in iOS 9.

To solve such a problem, annotate the functions according to the iOS version available.

Here is what I did to solve it:

@available(iOS 9.0, *)
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {

    return GIDSignIn.sharedInstance().handleURL(url, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey]! as! String, annotation: options[UIApplicationOpenURLOptionsAnnotationKey])
}

@available(iOS 8.0, *)
func application(application: UIApplication,
    openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {

    return GIDSignIn.sharedInstance().handleURL(url, sourceApplication: sourceApplication!, annotation: annotation)
}

Let me know if this solved your problem.

kerry
  • 2,362
  • 20
  • 33
  • Thanks now this working for OS 9.0. Pls let me know we have to use both delegates to support OS and OS 9.0 – Chandan Kumar Jha Apr 11 '16 at 05:31
  • Yes, you will have to use both of them. The annotation tells iOS which one to use. You will just have to write those two functions. – kerry Apr 11 '16 at 09:06