iOS Facebook SDK MessageDialog错误202

时间:2015-03-31 08:36:39

标签: ios facebook ios8 xcode6

我正在尝试在我的iOS应用中与FBSDK建立Facebook共享。

我一直在阅读文档here,目前有

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

使用内容对象 - FBSDKShareLinkContent

但是,在尝试使用Facebook Messenger共享指定的类似方法时,

[FBSDKMessageDialog showWithContent:content delegate:self];
我正在崩溃。我发现错误并将其记录在其中一个委托方法中,并指出"操作无法完成。 (com.facebook.sdk.share错误202.) "

我搜索了这个特定的错误,但没有找到任何直接相同的错误。这是完整的代码

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];
}

请原谅我,如果我遗漏了一些明显的东西,但正如this documentation所述,我认为FBSDKMessageDialog showWithContent:方法的工作方式与FBSDKShareDialog showFromViewController:的方法相同,这对我来说很有用。

  • 我使用的是最新版本的XCode和iOS8。

4 个答案:

答案 0 :(得分:6)

我必须登录然后发布,这就是它的工作原理:

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"]];
        }

    }
}];

和股份代表:

- (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");
}

编辑:

[messageDialog canShow]在iPad上返回NO,在iPhone上正常工作

Facebook Developers forum上发布了此问题。

答案 1 :(得分:2)

我坚持了一段时间,最后意识到我没有在fb-messenger-share-api文件的LSApplicationQueriesSchemes下添加info.plist。只是把它放在这里,以防有人帮忙。谢谢:)

  

N.B。。它是fb-messenger-share-api而不是fb-messenger-api

答案 2 :(得分:1)

注意:这更符合评论,但我还没有足够的声誉发表评论

我得到同样的错误,Facebook和Messenger都会更新。

我用

检查了我的权限
[[FBSDKAccessToken currentAccessToken] permissions]

我想我已经够了:

"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"

我尝试的方式与OP相同,我也尝试过:

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

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

[messageDialog canShow]返回 NO ,并且委托方法会在OP描述的202错误中捕获失败。

我尝试使用FBSDKSendButton,但似乎也没有。

另一方面,FBSDKShareDialog完美运作......

我希望这有助于解决问题。

答案 3 :(得分:1)

这在互联网搜索中再次冒出来。现在,对于代码为Message dialog is not available的错误202,有一个简单的答案:

Facebook's documentation

  

注意:目前iPad上不支持消息对话框。