FBSDKShareDialogModeNative 在分享点击时调用 sharerDidCancel
FBSDKShareDialogModeNative calls sharerDidCancel on Share click
我在通过 facebook-ios-sdk 分享 link 时遇到问题。
我需要使用 FBSDKShareDialogModeNative
来共享对话框,FBSDKShareDialogModeShareSheet
不适合我,因为我需要为给定的内容设置标题、描述和图像,这在这不起作用模式。我找到的每个答案都推荐这种模式。
当我使用 FBSDKShareDialogModeNative
时,本机 Facebook 应用程序会以正确的内容打开,但在点击“分享”按钮后,fb 应用程序会关闭,并且不会共享任何内容。还调用委托方法 sharerDidCancel
。
唯一能按预期工作的选项是通过浏览器以 FBSDKShareDialogModeFeedBrowser
模式共享。
示例代码:
FBSDKShareLinkContent *content = [FBSDKShareLinkContent new];
content.contentURL = [NSURL URLWithString:@"http://google.com"]; // Random
content.contentTitle = @"Test title"; // Random
content.contentDescription = @"Test description"; // Random
content.imageURL = [NSURL URLWithString:@"http://www.gettyimages.pt/gi-resources/images/Homepage/Hero/PT/PT_hero_42_153645159.jpg"]; // Random
FBSDKShareDialog *dialog = [FBSDKShareDialog new];
dialog.fromViewController = self;
dialog.shareContent = content;
dialog.delegate = self;
dialog.mode = FBSDKShareDialogModeNative;
if (![dialog canShow]) {
dialog.mode = FBSDKShareDialogModeFeedBrowser;
}
[dialog show];
有人解决过这个问题吗?
提前谢谢你。
您好,您需要使用此代码。
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc]init];
content.contentURL = [NSURL URLWithString:@"http://google.com"]; // Random
content.contentTitle = @"Test title"; // Random
content.contentDescription = @"Test description"; // Random
content.imageURL = [NSURL URLWithString:@"http://www.gettyimages.pt/gi-resources/images/Homepage/Hero/PT/PT_hero_42_153645159.jpg"];
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = self;
dialog.shareContent = content;
dialog.delegate = self;
dialog.mode = FBSDKShareDialogModeNative;
if (![dialog canShow]) {
dialog.mode = FBSDKShareDialogModeFeedBrowser;
}
[dialog show];
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc]init];
content.contentURL = [NSURL URLWithString:@"http://google.com"]; // Random
content.contentTitle = @"Test title"; // Random
content.contentDescription = @"Test description"; // Random
content.imageURL = [NSURL URLWithString:@"http://www.gettyimages.pt/gi-resources/images/Homepage/Hero/PT/PT_hero_42_153645159.jpg"]; //
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = self;
dialog.shareContent = content;
dialog.delegate = self;
dialog.mode = FBSDKShareDialogModeNative;
if (![dialog canShow])
{
dialog.mode = FBSDKShareDialogModeFeedBrowser;
}
[dialog show];
我发现我在 plist 中使用了错误的 FacebookDisplayName
。
SDK 不会给您任何警告(在 fb native 中点击 Done/Share 按钮后它会静默失败)并且在其他模式(shareSheet、feedBrowser 等)下使用错误的显示名称共享也有效。
我在通过 facebook-ios-sdk 分享 link 时遇到问题。
我需要使用 FBSDKShareDialogModeNative
来共享对话框,FBSDKShareDialogModeShareSheet
不适合我,因为我需要为给定的内容设置标题、描述和图像,这在这不起作用模式。我找到的每个答案都推荐这种模式。
当我使用 FBSDKShareDialogModeNative
时,本机 Facebook 应用程序会以正确的内容打开,但在点击“分享”按钮后,fb 应用程序会关闭,并且不会共享任何内容。还调用委托方法 sharerDidCancel
。
唯一能按预期工作的选项是通过浏览器以 FBSDKShareDialogModeFeedBrowser
模式共享。
示例代码:
FBSDKShareLinkContent *content = [FBSDKShareLinkContent new];
content.contentURL = [NSURL URLWithString:@"http://google.com"]; // Random
content.contentTitle = @"Test title"; // Random
content.contentDescription = @"Test description"; // Random
content.imageURL = [NSURL URLWithString:@"http://www.gettyimages.pt/gi-resources/images/Homepage/Hero/PT/PT_hero_42_153645159.jpg"]; // Random
FBSDKShareDialog *dialog = [FBSDKShareDialog new];
dialog.fromViewController = self;
dialog.shareContent = content;
dialog.delegate = self;
dialog.mode = FBSDKShareDialogModeNative;
if (![dialog canShow]) {
dialog.mode = FBSDKShareDialogModeFeedBrowser;
}
[dialog show];
有人解决过这个问题吗? 提前谢谢你。
您好,您需要使用此代码。
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc]init];
content.contentURL = [NSURL URLWithString:@"http://google.com"]; // Random
content.contentTitle = @"Test title"; // Random
content.contentDescription = @"Test description"; // Random
content.imageURL = [NSURL URLWithString:@"http://www.gettyimages.pt/gi-resources/images/Homepage/Hero/PT/PT_hero_42_153645159.jpg"];
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = self;
dialog.shareContent = content;
dialog.delegate = self;
dialog.mode = FBSDKShareDialogModeNative;
if (![dialog canShow]) {
dialog.mode = FBSDKShareDialogModeFeedBrowser;
}
[dialog show];
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc]init];
content.contentURL = [NSURL URLWithString:@"http://google.com"]; // Random
content.contentTitle = @"Test title"; // Random
content.contentDescription = @"Test description"; // Random
content.imageURL = [NSURL URLWithString:@"http://www.gettyimages.pt/gi-resources/images/Homepage/Hero/PT/PT_hero_42_153645159.jpg"]; //
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = self;
dialog.shareContent = content;
dialog.delegate = self;
dialog.mode = FBSDKShareDialogModeNative;
if (![dialog canShow])
{
dialog.mode = FBSDKShareDialogModeFeedBrowser;
}
[dialog show];
我发现我在 plist 中使用了错误的 FacebookDisplayName
。
SDK 不会给您任何警告(在 fb native 中点击 Done/Share 按钮后它会静默失败)并且在其他模式(shareSheet、feedBrowser 等)下使用错误的显示名称共享也有效。