Google-signin: Redirect to google.com after signing in

Created on 16 Nov 2016  路  9Comments  路  Source: react-native-google-signin/google-signin

On IP6s, after I called GoogleSignin.signIn() and enter email + password, the modal redirected to http://google.com instead of my app.
Tested on :
_ IP6s, IOS 10.0.2
"dependencies": {
"react": "15.3.2",
"react-native": "^0.36.1",
"react-native-google-signin": "^0.8.1",
"react-native-fbsdk": "^0.4.0",
},

Most helpful comment

The problem is react-native-google-signin conflicts with facebook sdk in AppDelegate.m. To fix this, edit AppDelegate.m as follows:

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

  if ([url.scheme hasPrefix:@"fb"]) {
    return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                          openURL:url
                                                sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                                       annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
            ];


  }else{
    return [[GIDSignIn sharedInstance] handleURL:url
                               sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                      annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];


      }
}

All 9 comments

The problem is react-native-google-signin conflicts with facebook sdk in AppDelegate.m. To fix this, edit AppDelegate.m as follows:

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

  if ([url.scheme hasPrefix:@"fb"]) {
    return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                          openURL:url
                                                sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                                       annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
            ];


  }else{
    return [[GIDSignIn sharedInstance] handleURL:url
                               sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                      annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];


      }
}

@nlt2390 Totally work. Thanks!

@tranduykhanh Does this still work for you? The code pasted here doesn't seem to be compatible with current instructions (GIDSignIn instead of RNGoogleSignin):

  return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                        openURL:url
                                              sourceApplication:sourceApplication
                                                     annotation:annotation
         ]
         || [RNGoogleSignin application:application
                                openURL:url
                      sourceApplication:sourceApplication
                             annotation:annotation
            ];

I have FB implemented and Google Sign-in works but if I cancel the sign-in on iOS app seems to crash/get stuck (I don't see any errors).

Just in case that someone try to integrate google sign-in with app which has integrated with 'wechat sign-in', with the code provided from @nlt2390, you need to change it to:
if ([url.scheme hasPrefix:@"wx"])
Since wechat uses wx{number} as schema string.

I am facing this issue again. Previously was working fine. I have done manual integration of iOS with react-native link command. Meaning, not used pods. :)

facing this issue since morning

+1 ...but nlt2390 save my day

// AppDelegate.m
- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<NSString *,id> *)options {
  return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url options:options] || [RNGoogleSignin application:application openURL:url options:options];
}

This is still a thing :-) - for ios9 and ios10. The code here is close but if you want to do linking too, then you have maybe 3 options (facebook, google, linking) instead of just returning from an or, it's better to do ifs I think? This is working for me:

#import <RNGoogleSignIn/RNGoogleSignIn.h>

// all the other stuff you have in AppDelegate.m here...

- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) {
    return YES;
  }

  if ([RNGoogleSignin application:app openURL:url options:options]) {
    return YES;
  }

  if ([RCTLinkingManager application:app openURL:url options:options]) {
    return YES;
  }

  return NO;
}
Was this page helpful?
0 / 5 - 0 ratings