简体   繁体   English

适用于iOS的Google登录SDK 2.0.1错误

[英]Google sign-in SDK 2.0.1 for iOS error

I'm trying to integrate the Google sign-in in my project for that i'm using 'Google sign-in SDK 2.0.1'. 我正在尝试将Google登录集成到我的项目中,因为我正在使用“ Google登录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 我已经按照developer.google网站上显示的步骤操作,但是当我单击按钮时,它在- (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error返回错误“未知错误” - (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 我已经集成了2个url方案和app-delegate,VC实现,如教程中所示

Here is the code for ViewController where i implement the Sign-in button 这是ViewController的代码,其中我实现了登录按钮

@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

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]; 您可能想通过运行pod try Google并使用[[GGLContext sharedInstance] configureWithError: &configureError];Google登录快速入门开始[[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: 如果不调用configureWithError ,则应设置客户端ID(通常在AppDelegate中完成),例如:

    [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 查看Web浏览器地址(如果您正在模拟器中进行测试),以确保将客户端ID传递到登录流程中

  • Make sure to add the reversed client ID to your URL Schemes 确保将反向的客户ID添加到您的URL方案中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM