【问题标题】:iOS Facebook SDK MessageDialog error 202iOS Facebook SDK MessageDialog 错误 202
【发布时间】:2015-03-31 08:36:39
【问题描述】:

我正在尝试在我的 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。

【问题讨论】:

  • 我无法重现该错误。您使用哪个版本的 Facebook Messenger 应用程序?您是否切换到 Messenger 应用程序? Facebook SDK 包含 RPSSample 项目,你能用那个项目重现吗?
  • 刚刚遇到同样的错误。你解决了这个问题吗?
  • 未解决。我使用自定义按钮遇到了这个问题,但后来改为 UIActivitySheet

标签: ios facebook ios8 xcode6


【解决方案1】:

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

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 上发布问题。

【讨论】:

  • 感谢您的意见。我不再在我的应用程序中实现代码进行测试,但如果其他人使用它,请确认,我会给出接受的答案
  • 我在我的一个应用中使用过它,但不知道是否有其他人使用过。
  • 我设法实现了它,它一直在工作,直到 [messageDialog canShow]。它跳到其他地方,但我认为那是因为我在模拟器上运行它。您能否详细说明我是否可以在模拟器上测试发送消息?否则它会完美运行。
  • @Septronic - 抱歉,您无法在模拟器上对其进行测试,因为您无法在其上安装 Messenger 应用程序。您需要安装了 FB messenger 的 iOS 设备来发送任何消息。
  • @aks5686 谢谢老兄,我会在我的手机上试试看效果如何:)
【解决方案2】:

我被这个问题困扰了一段时间,最后意识到我没有在LSApplicationQueriesSchemes 文件中的LSApplicationQueriesSchemes 下添加fb-messenger-share-api。只是把它放在这里以防它帮助某人。谢谢:)

注意这是fb-messenger-share-api而不是fb-messenger-api

【讨论】:

    【解决方案3】:

    注意:这更适合作为评论,但我还没有足够的声誉来发布 cmets

    我收到同样的错误,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 完美运行...

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

    【讨论】:

      【解决方案4】:

      这在互联网搜索中再次冒泡。 如今,错误 Message dialog is not available 有一个简单的答案,代码为 202

      Facebook's documentation:

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

      【讨论】:

        猜你喜欢
        • 2013-04-05
        • 2013-06-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多