Can';无法在facebook ios sdk中获取用户_生日和用户_家乡的权限
我无法获得用户生日和用户家乡的权限。 我以前用过这段代码,但它只要求公共配置文件,而忽略了其他文件Can';无法在facebook ios sdk中获取用户_生日和用户_家乡的权限,ios,facebook,facebook-graph-api,facebook-ios-sdk,Ios,Facebook,Facebook Graph Api,Facebook Ios Sdk,我无法获得用户生日和用户家乡的权限。 我以前用过这段代码,但它只要求公共配置文件,而忽略了其他文件 [FBSession openActiveSessionWithReadPermissions:@[@"public_profile",@"user_birthday",@"user_hometown"] allowLoginUI:YES completionHandler:^(FBSession *sessio
[FBSession openActiveSessionWithReadPermissions:@[@"public_profile",@"user_birthday",@"user_hometown"]
allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if (error) {
NBAppDelegate* appDel = (NBAppDelegate*)`[UIApplication sharedApplication].delegate;
[appDel sessionStateChanged:session state:status error:error];
}
if ([session isOpen]) {
[self loginWithFBToken:session name:sender];
}
}];
然后有人建议在获得公共配置文件后请求额外的权限,所以我甚至尝试了这样做,但效果不佳。
这是代码
- (void)loadFbDetails
{
NSArray *permissionsNeeded = @[@"user_hometown", @"user_birthday"];
// Request the permissions the user currently has
[FBRequestConnection startWithGraphPath:@"/me/permissions"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error){
// These are the current permissions the user has:
NSDictionary *currentPermissions= [(NSArray *)[result data] objectAtIndex:0];
// We will store here the missing permissions that we will have to request
NSMutableArray *requestPermissions = [[NSMutableArray alloc] initWithArray:@[]];
// Check if all the permissions we need are present in the user's current permissions
// If they are not present add them to the permissions to be requested
for (NSString *permission in permissionsNeeded){
if (![currentPermissions objectForKey:permission]){
[requestPermissions addObject:permission];
}
}
// If we have permissions to request
if ([requestPermissions count] > 0){
// Ask for the missing permissions
[FBSession.activeSession
requestNewReadPermissions:requestPermissions
completionHandler:^(FBSession *session, NSError *error) {
if (!error) {
// Permission granted
NSLog(@"new permissions %@", [FBSession.activeSession permissions]);
// We can request the user information
[self makeRequestForUserData];
} else {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
}
}];
} else {
// Permissions are present
// We can request the user information
[self makeRequestForUserData];
}
} else {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
}
}];
}
它所做的只是递归地在我的ios应用程序和fb本机应用程序之间切换,只返回权限数组中的public_配置文件。
看来我遗漏了什么 如果您使用的是该应用程序的管理员用户,那么它应该可以工作。一旦你想对其他用户使用扩展权限,你必须先让Facebook审查你的应用程序
请参见我的答案:默认情况下,Facebook不允许应用程序访问这些信息。你必须获得Facebook的许可才能使用这些信息。添加一段视频和说明,供Facebook员工查看您如何使用生日和家乡英特尔。如果您使用FB应用程序的管理员用户,这是否有效?我是开发人员(不是管理员?),我使用过该帐户?你认为这是一个问题吗?在代码方面没有任何错误吗?
-(void)makeRequestForUserData
{
[FBRequestConnection startWithGraphPath:@"me?fields=birthday,hometown"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Sucess! Include your code to handle the results here
NSLog(@"user events: %@", result);
} else {
NSLog(@"error: %@" , error);
}
}];
}