在此我的 fb-login 登录范围
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email", @"user_location"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
// Process error
NSLog(@"error %@",error);
} else if (result.isCancelled) {
// Handle cancellations
NSLog(@"Cancelled");
} else {
if ([result.grantedPermissions containsObject:@"email"]) {
// Do work
NSLog(@"%@",result);
}
}
}];
我正在使用以下代码从 facebook 检索用户名、用户 ID、电子邮件。
我无法检索用户的位置。帮帮我
NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
[parameters setValue:@"id,name,email,location" forKey:@"fields"];
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:parameters]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSLog(@"%@",result objectForKey:@"name");
}
}];