我尝试了许多方法来实现这一目标,但失败了。
我必须使用URL在facebook上共享信息,单击URL时,它将重定向到我的应用程序的特定页面。
let content: FBSDKShareLinkContent = FBSDKShareLinkContent() content.contentURL = NSURL(string: linkUrl) as URL! content.contentTitle = "Test" content.quote = "game" content.contentDescription = "This is a test game to test Fb share functionality" content.imageURL = NSURL(string: imgUrl) as URL! let dialog: FBSDKShareDialog = FBSDKShareDialog() dialog.mode = FBSDKShareDialogMode.native dialog.fromViewController = vc dialog.shareContent = content // if you don't set this before canShow call, canShow would always return YES if !dialog.canShow() { // fallback presentation when there is no FB app dialog.mode = FBSDKShareDialogMode.feedBrowser } dialog.show()
它正在工作并成功共享该帖子。当我单击链接时,它正在重定向到应用程序,没有太多信息可以重定向到特定的ViewController。
let properties = [ "fb:app_id": "Fb_id", "og:type": "article", "og:title": "Test", "og:description": "This is a test game to test Fb share functionality", "og:image" : urlImg, "og:url" : linkUrl, ] let object : FBSDKShareOpenGraphObject = FBSDKShareOpenGraphObject.init(properties: properties) // Create an action let action : FBSDKShareOpenGraphAction = FBSDKShareOpenGraphAction() action.actionType = "news.publishes" action.setObject(object, forKey: "article") // Create the content let content : FBSDKShareOpenGraphContent = FBSDKShareOpenGraphContent() content.action = action content.previewPropertyName = "article" FBSDKShareDialog.show(from: vc, with: content, delegate: nil)
在这里,我使用Open Graph发布并成功发布了信息。但是,单击链接时不要重定向到我的应用程序。
注意:
我没有网络应用程序。
我的目标是通过应用链接分享信息。单击该链接后,它将打开应用程序并重定向到特定页面(如果已安装应用程序),否则将重定向到AppStore。那么, 链接 格式应该是什么?如何建立链接以实现此功能?
请帮忙。
提前致谢
是的,我通过在服务器端设置元数据来实现此功能。
参考:https : //developers.facebook.com/docs/applinks
https://developers.facebook.com/docs/applinks/ios
谢谢…