本文介绍了如何使用Facebook iOS SDK 4.x“重新申请”电子邮件权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在将FacebookSDK 4.x与自定义UI集成,并使用以下方法登录并获取用户的电子邮件许可。 FBSDKLoginManager * login = [[FBSDKLoginManager alloc] init]; [login logInWithReadPermissions:@ [@email] handler:^(FBSDKLoginManagerLoginResult * result,NSError * error){ if(error){ NSLog(@%@ error localizedDescription]); } else if(result.isCancelled){ NSLog(@Cancled); } else { if([result.grantedPermissions containsObject:@email]) { NSLog(@授予所有权限 ); if([FBSDKAccessToken currentAccessToken]) { [[FBSDKGraphRequest alloc] initWithGraphPath:@me参数:nil] startWithCompletionHandler:^(FBSDKGraphRequestConnection * connection,id result,NSError * error ) { if(!error) { NSLog(@%@,result); } }]; } } else { NSLog(@未授予); } } }]; 除非用户拒绝访问电子邮件,否则这很好用。我在FacebookSDK文档中看到,我可以重新请求访问用户的电子邮件一次。根据FB文档:如链接中给出的那样, 如果有人拒绝了您的应用的权限,登录对话框将不会让您的应用重新请求权限,除非您通过auth_type = rerequest以及您的请求。 启用重新验证 只是问题是我正在调用注销 FbSDKLoginManager类的方法。这将清除令牌,它将把它作为旧许可不被重新请求的权限。 I am integrating FacebookSDK 4.x integration with custom UI and using following method to log-in and also getting email permission from user.FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; [login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { if (error){ NSLog(@"%@",[error localizedDescription]); } else if (result.isCancelled){ NSLog(@"Cancled"); } else { if ([result.grantedPermissions containsObject:@"email"]) { NSLog(@"Granted all permission"); if ([FBSDKAccessToken currentAccessToken]) { [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { if (!error) { NSLog(@"%@",result); } }]; } } else { NSLog(@"Not granted"); } } }];This works great unless the user denies access to "email". I see in the FacebookSDK docs that I can re-request access to the user's email one time. According to the FB docs: as given in this linkIf someone has declined a permission for your app, the login dialog won't let your app re-request the permission unless you pass auth_type=rerequest along with your request.Enabling Re-authenticationHow do I pass "auth_type=rerequest" to Facebook's servers via the iOS SDK? Is there a special method for that? 解决方案 I resolved issue by recalling the method :[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)I need to pass auth_type: 'rerequest' while requesting again and i get it in the documentation of this method i get the description :just the problem was i was calling logout Method of FbSDKLoginManager class. This will clear the token and it will takes it as the old permission not re-requested permission. 这篇关于如何使用Facebook iOS SDK 4.x“重新申请”电子邮件权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-12 23:56