iOS Facebook SDK MessageDialog error 202

前端 未结 4 831
余生分开走
余生分开走 2021-02-06 02:43

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 showF         


        
相关标签:
4条回答
  • 2021-02-06 03:03

    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.

    0 讨论(0)
  • 2021-02-06 03:05

    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.

    0 讨论(0)
  • 2021-02-06 03:09

    This bubbled up again in an interweb search. Nowadays, there is a simple answer for the error Message dialog is not available with code 202:

    Facebook's documentation:

    Note: Currently the message dialog is not supported on iPads.

    0 讨论(0)
  • 2021-02-06 03:21

    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.

    0 讨论(0)
提交回复
热议问题