Search code examples
facebookfacebook-graph-apifacebook-ios-sdkfacebook-permissions

pages_messaging permission facebook iOS SDK subscribe to page


I'm trying with the Facebook iOS SDK to subscribe to a page so that I can utilize a web hook and receive updates when a person comments on the page. However, It does not work.

I request these login permissions:

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
            [login logInWithPublishPermissions:@[@"manage_pages", @"publish_pages"] 

And grant permission.

But then, when I make this graph API call

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:[NSString stringWithFormat:@"/%@/subscribed_apps", page_id] parameters:nil tokenString:token version:nil HTTPMethod:@"POST"];

I get this error:

permission pages_messaging is required to register webhook for messages or deliveries

So, when I attempt to request that permission at login it gives me yet another error:

Request:

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

    }];

Error Screen:

error screen

I've looked all over Facebook's Doc's and can't find an explanation as to what I'm doing incorrectly. Is there some other way to request this permission?

The page I am trying to subscribe to is owned by the user and it's a business page - not a personal page.


Solution

  • Permission pages_messaging was introduced with API v2.6.

    Your app seems to be using an older API version - and using that, you can not ask for that permission.

    So you have to upgrade your app to use API version 2.6 first, before you can ask for it.

    https://developers.facebook.com/docs/apps/versions