如何使用FB iOS SDK获取用户位置?

时间:2015-10-12 07:55:27

标签: ios facebook-graph-api fbsdk

因此我的登录范围为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");
             }
         }];

0 个答案:

没有答案