通过Google Plus登录到本机应用程序不会每次都显示登录页面吗? [英] Login through google plus to native app does not shows login page every time?

查看:85
本文介绍了通过Google Plus登录到本机应用程序不会每次都显示登录页面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个供用户使用google +登录到应用程序的选项吗?在用户首次点击google plus按钮时,登录页面仅显示一次,而下次我单击google plus按钮时,登录页面仅显示一次导航到权限页面,而不是登录login

in my app have a option for user to login to the app using google +?Here Login page is showing only once for the first time when user taps on google Plus button from next time when i click on google plus button its directly navigation to permissions page instead of going to loginPage

我的代码是

/////////////登录密码

//////////////CODE FOR LOGIN

GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.delegate = self;
signIn.shouldFetchGooglePlusUser = YES;
signIn.shouldFetchGoogleUserEmail = YES;  // Uncomment to get the user's email
signIn.shouldFetchGoogleUserID= YES;
signIn.clientID = kClientId;
signIn.scopes = [NSArray arrayWithObjects:
                 kGTLAuthScopePlusLogin, // defined in GTLPlusConstants.h
                 nil];
signIn.actions = [NSArray arrayWithObjects:@"http://schemas.google.com/ListenActivity",nil];
[signIn authenticate];

////////////////////////用于注销的代码

/////////////////////////CODE FOR LOGOUT

  - (void)Logout:(id)sender {

     [[GPPSignIn sharedInstance] signOut];
    [self performSelector:@selector(disconnect) withObject:nil afterDelay:1.0f];
   }
   - (void)disconnect {
[[GPPSignIn sharedInstance] disconnect];
  }

推荐答案

用户对您进行身份验证后,GPP库将刷新令牌存储在钥匙串中.下次他们回来时,您可以致电trySilentAuthentication来检查他们是否可以自动登录.

Once the user has authenticated with you, the GPP library stores a refresh token in the keychain. Next time they come back you can call trySilentAuthentication to check whether they can sign-in automatically.

如果您确实退出并再次致电身份验证,则如果他们已在该设备上获得同意,则该应用不会显示同意屏幕.在这种情况下,您尝试断开连接以强制执行该操作,但是由于您是在注销令牌后将其删除的,因此您必须执行此操作.

If you do sign out and call authenticate again, the app wont show them a consent screen if they've already granted consent on that device. In this case, you are trying to disconnect to force it, but because you're doing it after the sign out the tokens have already been removed.

如果您希望用户每次都看到登录屏幕(尽管这听起来不是很好的体验!),只需存储一个本地标志(是否已这样做),就不要调用身份验证直到那一点.

If you want your users to see the sign-in screen each time (though that doesn't sound like a very good experience!) just store a local flag for whether they've done so, and don't call authenticate until that point.

这篇关于通过Google Plus登录到本机应用程序不会每次都显示登录页面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆