本文介绍了iOS Facebook SDK MessageDialog错误202的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 showFromViewController:self withContent:content delegate:self];

使用内容对象 - FBSDKShareLinkContent

working with a content object - FBSDKShareLinkContent.

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

However, upon trying to use the similar method as specified for Facebook Messenger sharing,

[FBSDKMessageDialog showWithContent:content delegate:self];

我遇到了崩溃。我发现错误并将其记录在其中一个委托方法中,并指出操作无法完成。(com.facebook.sdk.share error 202.)

i am getting a crash. I caught the error and logged it in one of the delegate methods, and it states "The operation couldn’t be completed. (com.facebook.sdk.share error 202.)"

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

I have searched for this specific error but have not found anything directly with the same error. Here is full code

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

如果我遗漏了明显的东西,请原谅我,但是读取,我假设 FBSDKMessageDialog showWithContent:方法将以相同的方式工作as FBSDKShareDialog showFromViewController:这对我有用。

Forgive me if i am missing something obvious, but as this documentation reads, i assume the FBSDKMessageDialog showWithContent: method would work the same way as FBSDKShareDialog showFromViewController: which is working for me.


  • 我正在使用最新的带iOS8的XCode版本。

推荐答案

我必须登录然后发布,这是怎么回事它起作用了:

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

    }
}];

和股份代表:

- (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上正常工作

[messageDialog canShow] returns NO on the iPad, works fine on iPhone

在。

这篇关于iOS Facebook SDK MessageDialog错误202的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 18:37