" sharerDidCancel:"在未安装Facebook应用程序时首次成功分享后调用

时间:2018-03-29 13:16:03

标签: ios facebook facebook-share facebook-sdk-4.x

我使用UIButton与Facebook的SDK 4.31.1共享。点击后,会显示一个共享对话框。

- (IBAction)btnSharePressed:(id)sender
{
    [self displayShareDialog];
}

- (void)displayShareDialog {
    FBSDKShareLinkContent *content = [self getShareContent];

    if ([FacebookHandler isFacebookAppInstalled]) {
        [FBSDKShareDialog showFromViewController:self
                                     withContent:content
                                        delegate:self];
    } else {
        FBSDKShareDialog * shareDialog = [[FBSDKShareDialog alloc] init];
        [shareDialog setMode:FBSDKShareDialogModeBrowser];
        [shareDialog setDelegate:self];
        [shareDialog setFromViewController:self];
        [shareDialog setShareContent:content];
        [shareDialog show];
    }
}

// Expects the URL of the scheme e.g. "fb://"
+ (BOOL)isFacebookAppInstalled {
    NSArray* fbSchemes = @[@"fbapi://",
                           @"fb-messenger-api://",
                           @"fbauth2://",
                           @"fbshareextension://"];
    BOOL isInstalled = false;

    for (NSString* fbScheme in fbSchemes) {
        isInstalled = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:fbScheme]];
        if(isInstalled) {
            break;
        }
    }
    return isInstalled;
}

但是当没有安装Facebook应用程序时,在每次启动时,在第一次成功共享时调用委托方法sharerDidCancel:,并且在任何进一步成功的共享上调用正确的委托方法sharer:didCompleteWithResults:。 我已在FacebookDisplayName文件中正确设置FacebookIdplist,因此不是这样。 我还尝试用FBSDKShareDialogModeBrowser切换FBSDKShareDialogModeFeedBrowser但没有运气。

有人可以解释为什么首先调用cancel方法,即使共享已成功完成,为什么只有在第一次共享后呢?

0 个答案:

没有答案