微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

iOS Facebook SDK MessageDialog错误202

我想在我的iOS应用程序中与FBSDK建立Facebook共享.

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

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

使用内容对象 – FBSDKShareLinkContent.

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

[FBSDKMessageDialog showWithContent:content delegate:self];

我正在崩溃.我发现错误并将其记录在其中一个委托方法中,并指出“操作无法完成.(com.facebook.sdk.share error 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.

解决方法

我必须登录然后发布,这是它的工作原理:
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上发布了这个问题.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐