[英]Google sign-in SDK 2.0.1 for iOS error
我正在嘗試將Google登錄集成到我的項目中,因為我正在使用“ Google登錄SDK 2.0.1”。 我已經按照developer.google網站上顯示的步驟操作,但是當我單擊按鈕時,它在- (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error
返回錯誤“未知錯誤” - (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error
我已經集成了2個url方案和app-delegate,VC實現,如教程中所示
這是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
具體的錯誤代碼是什么? 通常,您會看到一條消息,並返回以下異常:
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)'
同時需要幫助診斷的幾件事:
您可能想通過運行pod try Google
並使用[[GGLContext sharedInstance] configureWithError: &configureError];
從Google登錄快速入門開始[[GGLContext sharedInstance] configureWithError: &configureError];
配置項目
如果不調用configureWithError
,則應設置客戶端ID(通常在AppDelegate中完成),例如:
[GIDSignIn sharedInstance].clientID = "YOUR_CLIENT_ID";
查看Web瀏覽器地址(如果您正在模擬器中進行測試),以確保將客戶端ID傳遞到登錄流程中
確保將反向的客戶ID添加到您的URL方案中
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.