I am trying to get Feed for logged in user's timeline. I have a login button, to which I am passing read permissions including user_posts
. Amazingly, Facebook does not grant me this permission and ignores it.
Code:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends", @"user_posts"];
self.loginButton.delegate = self;
if([FBSDKAccessToken currentAccessToken])
{
NSLog(@"Have access token");
NSLog(@"permissions .... %@",[FBSDKAccessToken currentAccessToken].permissions);
[self retrieveFeed];
}
}
#pragma mark - Login Delegate
-(void) loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
{
NSLog(@"Login Successfully!!");
NSLog(@"permissions .... %@",[FBSDKAccessToken currentAccessToken].permissions);
[self retrieveFeed];
}
-(void) loginButtonDidLogOut:(FBSDKLoginButton *)loginButton
{
}
#pragma mark - Receive FB Feed
-(void) retrieveFeed
{
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/me/feed" parameters:nil];
FBSDKGraphRequestConnection *connection = [[FBSDKGraphRequestConnection alloc] init];
[connection addRequest:request completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
NSLog(@"%@",result);
if(error)
NSLog(@"Some error FEED;;;;;; %@",error.localizedDescription);
}];
[connection start];
}
On Clicking login Button, I get following permissions screen. Facebook has ignored user_posts
permission.
Even if I try to get this permission later after login, Facebook tells me that I have already authorized app to do so, even when there is no such permission granted! The code for getting new permission is:
-(void) checkForFeedPermission
{
if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"user_posts"]) {
NSLog(@"already granted feed access");
[self retrieveFeed];
} else {
FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
[loginManager logInWithReadPermissions:@[@"user_posts"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
NSLog(@"requesting feed access");
[self retrieveFeed];
}];
}
}
I have been banging my head on this issue for three days. Please suggest me where can I be wrong? Thanks.
I think that not working for grant user_posts
as par Facebook developer documentation for permission you have to submit your Facebook app for review see i attach screenshot that clearly said.
So you have to submit your facebook app for login review might be then you can able to set this permission at loginTime
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With