存储谷歌应用程序权限-iOS
我不熟悉iOS开发/目标C,所以请温柔一点- 我正在创建一个使用Google+登录SDK的应用程序,我有一个工作原型,用户点击Google登录按钮,然后将他们重新定向到safari,在那里他们登录到自己的Google帐户,最后显示我的应用程序的帐户权限屏幕,然后返回iOS应用程序 我遇到的问题是,在允许应用程序访问相关信息后,用户在通过Google登录应用程序时会不断导航到帐户权限屏幕 现在,我的印象是,一旦用户允许应用程序访问相关信息,则不会要求用户批准,除非他们通过security.google.com撤销访问权限,但我发现每次登录尝试后,我总是必须批准权限 以前有人有过这个问题吗?我在谷歌上搜索了几次,寻找这个问题的答案,但运气不太好。任何帮助都将不胜感激 谢谢 代码如下:存储谷歌应用程序权限-iOS,ios,google-authentication,Ios,Google Authentication,我不熟悉iOS开发/目标C,所以请温柔一点- 我正在创建一个使用Google+登录SDK的应用程序,我有一个工作原型,用户点击Google登录按钮,然后将他们重新定向到safari,在那里他们登录到自己的Google帐户,最后显示我的应用程序的帐户权限屏幕,然后返回iOS应用程序 我遇到的问题是,在允许应用程序访问相关信息后,用户在通过Google登录应用程序时会不断导航到帐户权限屏幕 现在,我的印象是,一旦用户允许应用程序访问相关信息,则不会要求用户批准,除非他们通过security.goog
- (void)viewDidLoad {
[super viewDidLoad];
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGooglePlusUser = YES; // get the user profile
signIn.shouldFetchGoogleUserEmail = YES; // get the user's email
signIn.scopes = @[ @"profile" ]; // "profile" scope
// Optional: declare signIn.actions, see "app activities"
signIn.delegate = self;
[signIn trySilentAuthentication];
}
- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error {
GTLQueryPlus *query = [GTLQueryPlus queryForPeopleGetWithUserId:@"me"];
// 1. Create a |GTLServicePlus| instance to send a request to Google+.
GTLServicePlus* plusService = [[GTLServicePlus alloc] init] ;
plusService.retryEnabled = YES;
// 2. Set a valid |GTMOAuth2Authentication| object as the authorizer.
[plusService setAuthorizer:[GPPSignIn sharedInstance].authentication];
// 3. Use the "v1" version of the Google+ API.*
plusService.apiVersion = @"v1";
[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusPerson *person,
NSError *error)
{
if (error) {
NSLog(@"Received Error %@ and auth object==%@", error, auth);
}
else {
// Send the basic user information to the console
NSLog(@"Email=%@", [GPPSignIn sharedInstance].authentication.userEmail);
NSLog(@"User Name=%@", [person.name.givenName stringByAppendingFormat:@" %@", person.name.familyName]);
[self performSegueWithIdentifier:@"loginSuccessful" sender:self]; // Once logged in send user to main view
}
我想您正在寻找trySilentAuthentication,它是google登录SDK的一部分。你可以在这里找到使用它的人:嘿,谢谢你的快速回复。我在登录视图控制器的viewDidLoad方法中使用这个,除非这是不正确的位置?不,这是正确的位置。你能分享你的代码吗?好的,我已经为处理登录功能的两个方法添加了代码。