我正在使用 google sign 从 google 获得身份验证然后形成我们的应用服务器
按照此处所述通过谷歌实现登录 https://developers.google.com/identity/sign-in/ios/start-integrating
当我点击 google 按钮并输入我的 google 凭据时,一切正常,但如果我想更改 google 帐户,我无法这样做
如果我再次点击 google 按钮,它不会要求添加其他帐户或给我现有帐户列表
它只是让我使用以前使用的帐户静默登录
我遵循的步骤
- 设置客户端 ID :在 Info 和 App Delegate 中设置客户端 ID
[GIDSignIn sharedInstance].clientID = @"xxxx.apps.googleusercontent.com";
- 设置委托(delegate):在 View Controller 中设置委托(delegate)
[GIDSignIn sharedInstance].delegate = self; [GIDSignIn sharedInstance].uiDelegate = self;
调用登录:一旦用户点击登录按钮,下面就是代码
- (IBAction)googlePlusSignInAction:(id)发件人{ [GMDCircleLoader setOnView:self.view withTitle:@""animated:YES]; [[GIDSignIn sharedInstance] 签名
在]; }
调用注销:一旦从谷歌获取个人资料详细信息,然后从谷歌注销
//关闭“使用 Google 登录” View
(void)signIn:(GIDSignIn *)signIn dismissViewController:(UIViewController *)viewController { [ self dismissViewControllerAnimated:YES 完成:nil];
(void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)用户 withError:(NSError *)error { [GMDCircleLoader hideFromView:self.view animated:YES]; //在此处对登录用户执行任何操作。 [[GIDSignIn sharedInstance] signOut];
我不确定我哪里错了我检查了 Jbong 应用程序,但我的应用程序的行为与此不同并且不符合预期
之前也尝试过注销
[[GIDSignIn sharedInstance] signOut]; [[GIDSignIn sharedInstance] 登录];
最佳答案
基本上,您需要注销并断开用户帐户,可能是为了选择其他帐户进行登录。您似乎从来没有在代码中的适当位置这样做过。在登录之前,您应该退出现有 session ,然后尝试登录。
swift
GIDSignIn.sharedInstance().signOut()
GIDSignIn.sharedInstance().disconnect()
objective-C
[[GIDSignIn sharedInstance] signOut];
[[GIDSignIn sharedInstance] disconnect];
关于ios - Google 登录向导不要求添加新帐户或选择现有帐户 - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49519161/