gpt4 book ai didi

ios - 适用于 iOS 的 Facebook SDK : FBSDKShareDialog is not shown

转载 作者:可可西里 更新时间:2023-11-01 00:37:12 25 4
gpt4 key购买 nike

我是 iOS 新手,我想使用适用于 iOS 的 Facebook SDK 分享一个链接。我的代码如下:

@IBAction func shareVoucherUsingFacebook(sender: UIButton) {
print("Facebook")
let content : FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: "www.google.com")
content.contentTitle = "Content Title"
content.contentDescription = "This is the description"

let shareDialog: FBSDKShareDialog = FBSDKShareDialog()

shareDialog.shareContent = content
shareDialog.delegate = self
shareDialog.fromViewController = self
shareDialog.show()

}

我也实现了 FBSDKSharingDelegate 方法,但是当我按下这个按钮时我无法接收到共享对话框,并且方法 func sharer(sharer: FBSDKSharing!, didFailWithError error : NSError!) 正在执行,这意味着出了点问题,但我想不通。

提前致谢。

最佳答案

改变这一行

content.contentURL = NSURL(string: "www.google.com")

进入

content.contentURL = NSURL(string: "https:\\www.google.com")

和我一起工作

这是我使用的委托(delegate)方法

func sharer(sharer: FBSDKSharing!, didCompleteWithResults results: [NSObject: AnyObject])
{
print(results)
}

func sharer(sharer: FBSDKSharing!, didFailWithError error: NSError!)
{
print("sharer NSError")
print(error.description)
}

func sharerDidCancel(sharer: FBSDKSharing!)
{
print("sharerDidCancel")
}

关于ios - 适用于 iOS 的 Facebook SDK : FBSDKShareDialog is not shown,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33290566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com