Facebook profile link of some facebook user is declined in response using FBSDKLoginManager in iOS app

119 Views Asked by At

I'm using FBSDKLoginKit to login with Facebook. I'm trying to get email, name, public profile and user profile link. According to latest policy to get profile link, developer need to ask permission during login and should provide how the information are being used to Facebook for review. I did all those process.

I was able to get all those required parameters when login with my developer Facebook account using FBSDKLoginManager. But when I tried login with another user account, profile link was declined in response. The link was empty.

I've created a method as below to login and get those parameters.

- (void)loginFaceBook
{
    FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
    login.loginBehavior = FBSDKLoginBehaviorSystemAccount;
    // need permission

    [login logInWithReadPermissions:@[@"public_profile", @"email", @"user_link"]
                 fromViewController:self
                            handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
     {

         if (error)
         {
             NSLog(@"Process error"); 
         }
         else if (result.isCancelled)
         {
             NSLog(@"Cancelled");
         }
         else
         {
             NSLog(@"Logged in");

             if ([result.grantedPermissions containsObject:@"email"])
             {
                 NSDictionary *params = @{@"fields" : @"id,name,link,email"};

                 [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:params]
                  startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id responseData, NSError *error)
                  {
                       NSLog(@"%@",responseData);
                      if (!error)
                      {
                          NSString *fbEmail = [AQCommon validateTextBeforePack:[responseData objectForKey:kEmail]];
                          NSString *fblink = [AQCommon validateTextBeforePack:[responseData objectForKey:@"link"]];
                          NSString *fbname = [AQCommon validateTextBeforePack:[responseData objectForKey:@"name"]];


                      }
                      else
                      {
                          NSLog(@"Facebook login failed. Please try later.");                  }
                      }
                  }];
             }
             else
             {
                 NSLog(@"Facebook login failed. Please try later.");                  }

         }

     }];
}

I got all the required parameters login with my Facebook developer account (where I've created my app), but user_link was declined for some other accounts. What could be the problem? Is it related to Facebook privacy policy? Or, user needs to change some settings in their profile?

Apart from the above problem, the profile link that I got of my developer account was opening from any Facebook account except some accounts. The error says either the link is expired or permission is not granted. The problem is very specific to Facebook user accounts. What could be the reasons and solutions?

2

There are 2 best solutions below

1
9to5ios On

Facebook provides sandboxed test users which can use be used for testing purposes.

Here you can check all about Facebook test users.

https://developers.facebook.com/docs/apps/test-users

0
user3853770 On

It seems that facebook allow to see the profile only if the user is friend or friend of friend.