iOS Facebook SDK MessageDialog错误202

前端之家收集整理的这篇文章主要介绍了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上发布了这个问题.

原文链接:https://www.f2er.com/iOS/333634.html

猜你在找的iOS相关文章