Login through google plus to native app does not s

2019-08-07 18:11发布

问题:

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

My code is

//////////////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];
  }

回答1:

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.