Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Facebook SDK MessageDialog error 202

I am trying to set up Facebook sharing with FBSDK in my iOS app.

I have been reading the documentation here, and currently have

[FBSDKShareDialog showFromViewController:self withContent:content delegate:self];

working with a content object - FBSDKShareLinkContent.

However, upon trying to use the similar method as specified for Facebook Messenger sharing,

[FBSDKMessageDialog showWithContent:content delegate:self];

i am getting a crash. I caught the error and logged it in one of the delegate methods, and it states "The operation couldn’t be completed. (com.facebook.sdk.share error 202.) "

I have searched for this specific error but have not found anything directly with the same error. Here is full code

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:kAPPShareLink];
content.contentDescription = kAPPShareDescription;
content.contentTitle = kAPPShareTitle;

if (buttonIndex == 0) {
    // Facebook

    [FBSDKShareDialog showFromViewController:self withContent:content delegate:self];
} else if (buttonIndex == 1) {
    // Facebook Messenger

    [FBSDKMessageDialog showWithContent:content delegate:self];
}

Forgive me if i am missing something obvious, but as this documentation reads, i assume the FBSDKMessageDialog showWithContent: method would work the same way as FBSDKShareDialog showFromViewController: which is working for me.

  • I am using the latest version of XCode with iOS8.
like image 650
rld001 Avatar asked Mar 31 '15 08:03

rld001


3 Answers

I had to login and then Post , that is how it worked :

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];


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

    if (error)
    {
    // Process error
    }
    else if (result.isCancelled)
    {
        // Handle cancellations
    }
    else
    {
        FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
        content.contentURL = [NSURL URLWithString:@"https://developers.facebook.com/"];

        FBSDKMessageDialog *messageDialog = [[FBSDKMessageDialog alloc] init];
        messageDialog.delegate = self;
        [messageDialog setShareContent:content];

        if ([messageDialog canShow])
        {
            [messageDialog show];
        }
        else
        {
            // Messenger isn't installed. Redirect the person to the App Store.
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/en/app/facebook-messenger/id454638411?mt=8"]];
        }

    }
}];

and the Share Delegate :

- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results
{
    NSLog(@"didCompleteWithResults");
}

- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{
    NSLog(@"didFailWithError ::: %@" , error);
}

- (void)sharerDidCancel:(id<FBSDKSharing>)sharer
{
    NSLog(@"sharerDidCancel");
}

Edit:

[messageDialog canShow] returns NO on the iPad, works fine on iPhone

Posted the issue on Facebook Developers forum.

like image 76
aks5686 Avatar answered Oct 08 '22 11:10

aks5686


I was stuck with this for a while and in the end realised that I had not added fb-messenger-share-api under LSApplicationQueriesSchemes in the info.plist file. Just putting this here in case it helps someone. Thanks :)

N.B. It is fb-messenger-share-api and not fb-messenger-api.

like image 23
GoGreen Avatar answered Oct 08 '22 11:10

GoGreen


Note: This fits more as a comment, but I don't have enough reputation yet to post comments

I get the same error, both Facebook and messenger are updated.

I checked my permissions with

[[FBSDKAccessToken currentAccessToken] permissions]

and I think I have enough:

"contact_email",
"publish_stream",
"user_likes",
"publish_checkins",
"video_upload",
"create_note",
"basic_info",
"publish_actions",
"public_profile",
"photo_upload",
"status_update",
email,
"user_friends",
"share_item"

I tried the same way as OP, and also I tried that:

FBSDKMessageDialog *messageDialog = [[FBSDKMessageDialog alloc] init];
[messageDialog setShareContent:content];
messageDialog.delegate = self;

if ([messageDialog canShow]) {
    [messageDialog show];        
}

[messageDialog canShow] returns NO, and the delegate methods catch the fail with the 202 error described by the OP.

I tried using the FBSDKSendButton, and doesn't seem to work either.

On the other hand, FBSDKShareDialog works perfectly...

I hope this helps to solve the issue.

like image 36
SFWdc Avatar answered Oct 08 '22 12:10

SFWdc