无法从iOS分享到Facebook Messenger

时间:2018-05-30 09:36:27

标签: ios facebook sdk facebook-messenger

我正在尝试将我的游戏中的一些文字分享给Facebook使者。

使用最新的Facebook iOS SDK(4.33),并复制Facebook文档中的示例,我收到以下错误:

-canOpenURL: failed for URL: "fb-messenger-share-api:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

我添加了" fb-messenger-share-api"到" LSApplicationQueriesSchemes"在info.plist中。如果我理解正确,此错误意味着未安装应用程序。但它已安装......

这是我正在使用的代码(实际上只是从示例中复制而来):

FBSDKShareMessengerURLActionButton *urlButton = [[FBSDKShareMessengerURLActionButton alloc] init];
urlButton.title = @"Visit Facebook";
urlButton.url = [NSURL URLWithString:@"https://www.facebook.com"];

FBSDKShareMessengerGenericTemplateElement *element = [[FBSDKShareMessengerGenericTemplateElement alloc] init];
element.title = @"This is a Cat Picture";
element.subtitle = @"Look at this cat, wow! Amazing.";
element.imageURL = [NSURL URLWithString:@"https://static.pexels.com/photos/126407/pexels-photo-126407.jpeg"];
element.button = urlButton;

FBSDKShareMessengerGenericTemplateContent *content = [[FBSDKShareMessengerGenericTemplateContent alloc] init];
content.pageID = "1";// Your page ID, required for attribution
content.element = element;

FBSDKMessageDialog *messageDialog = [[FBSDKMessageDialog alloc] init];
messageDialog.shareContent = content;

if ([messageDialog canShow]) {
    [messageDialog show];
}

canShow方法使用正确的url方案调用canOpenURL,这会产生错误。

任何想法在这里可能有什么问题?文档非常蹩脚......

0 个答案:

没有答案