Josh
Josh

Reputation: 743

How to properly request facebook permissions ios

I am trying to retrieve a bunch of facebook information from user using the app using parse and the facebook sdk, but I haven't been able to do it successfully.

First I check if the user is logged in and if they arn't I display the parse view controller with facebook permissions.

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];

if (![PFUser currentUser] || ![PFFacebookUtils isLinkedWithUser:[PFUser currentUser]]) {

    NSArray *permissionsArray = @[@"public_profile", @"user_birthday", @"user_photos", @"user_about_me", @"user_likes", @"user_relationship_details"];

    LoginViewController *logInViewController = [[LoginViewController alloc] init];
    [logInViewController setDelegate:self];

    [logInViewController setFacebookPermissions:[NSArray arrayWithObjects:permissionsArray, nil]];

    [logInViewController setFields:PFLogInFieldsFacebook | PFLogInFieldsDismissButton];

    [self presentViewController:logInViewController animated:YES completion:NULL];

} else {
        [self getUserInfo];
    }
}

Then, once the user is logged in, I attempt to get the following permissions like so.

-(void)getUserInfo {

FBSDKGraphRequest *requestMe = [[FBSDKGraphRequest alloc]initWithGraphPath:@"me" parameters:nil];
FBSDKGraphRequest *requestBirthday = [[FBSDKGraphRequest alloc]initWithGraphPath:@"me/user_birthday" parameters:nil];
FBSDKGraphRequest *requestPhotos = [[FBSDKGraphRequest alloc]initWithGraphPath:@"me/photos" parameters:nil];
FBSDKGraphRequest *requestAboutMe = [[FBSDKGraphRequest alloc]initWithGraphPath:@"me/about_me" parameters:nil];
FBSDKGraphRequest *requestLikes = [[FBSDKGraphRequest alloc]
                                   initWithGraphPath:@"/me/likes"
                                   parameters:nil
                                   HTTPMethod:@"GET"];
FBSDKGraphRequest *requestRelationship = [[FBSDKGraphRequest alloc]initWithGraphPath:@"me/relationship_details" parameters:nil];


FBSDKGraphRequestConnection *connection = [[FBSDKGraphRequestConnection alloc] init];

[connection addRequest:requestMe completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    userName = result[@"name"];
    userGender = result[@"gender"];
    userId = result[@"id"];

    if (connection) {
        [self setMe];
    }

}];

[connection addRequest:requestBirthday completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

}];

[connection addRequest:requestPhotos completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

}];

[connection addRequest:requestAboutMe completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

}];

[connection addRequest:requestLikes completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

}];

[connection addRequest:requestRelationship completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

}];


    [connection start];

}

The requestMe works perfectly and I retrieve the users information, however when I get the NSLog to output the result of any of the other permissions, its always null and I'm not sure what I am doing wrong. In the documentation it says that the app doesn't have to go through review if the developer wants to retrieve information about himself, so the problem isn't that the app hasn't been reviewed.

Why can't I retrieve the information? Is it because I am requesting the information wrong? Any help would be greatly appreciated!

Upvotes: 0

Views: 509

Answers (1)

Tobi
Tobi

Reputation: 31479

You cannot request extended permissions if your app didn't went through Login Review yet. The only exception is if you're using a admin/tester/developer user while testing your app.

See

Upvotes: 1

Related Questions