Google sign-in SDK 2.0.1 for iOS error

3.5k views Asked by At

I'm trying to integrate the Google sign-in in my project for that i'm using 'Google sign-in SDK 2.0.1'. I have follow the steps shown on developer.google site but when i click on the button it returns with error 'Unknown error' in - (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error

I have integrated 2 url schemes and app-delegate,VC implementation as shown in tutorial

Here is the code for ViewController where i implement the Sign-in button

@interface ViewController () < GIDSignInUIDelegate,GIDSignInDelegate>
@property (weak, nonatomic) IBOutlet GIDSignInButton *btnSignin;

@end

@implementation ViewController

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [GIDSignIn sharedInstance].uiDelegate = self;
    [GIDSignIn sharedInstance].delegate = self;

}

// ---------------------------------------------------------------------

#pragma mark - GIDSignInDelegate

- (void)signIn:(GIDSignIn *)signIn
didSignInForUser:(GIDGoogleUser *)user
     withError:(NSError *)error {
    if (error) {
        NSLog(@"Error in signin %@",[error localizedDescription]);
        return;
    }
}

// ---------------------------------------------------------------------


- (void)signIn:(GIDSignIn *)signIn
didDisconnectWithUser:(GIDGoogleUser *)user
     withError:(NSError *)error {
    if (error) {
        NSLog(@"Error did disconnect %@",[error localizedDescription]);
        return;
    }
}

@end
1

There are 1 answers

2
class On BEST ANSWER

What is the specific error code? Generally, you will see a message returned along with the exception:

2015-06-18 16:36:49.463 SignInExample[20038:2727845] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Your app must support the following URL schemes: (null)'

A few things to help diagnose in the meantime:

  • You might want to start from the Google Sign-in quickstart by running pod try Google and use [[GGLContext sharedInstance] configureWithError: &configureError]; to configure the project

  • If you are not calling configureWithError, you should be setting the client ID, typically done in your AppDelegate, for example:

    [GIDSignIn sharedInstance].clientID = "YOUR_CLIENT_ID";

  • Look at the web browser address (if you're testing in the simulator) to make sure that the client ID is getting passed to the sign in flow

  • Make sure to add the reversed client ID to your URL Schemes