我刚开始在 iOS 上使用 Facebook idk,并希望允许用户从我的应用程序中共享图像、标题和描述,如下所示:
但我只得到标题和描述:s 这是我的代码:
let imageType: FBSDKSharePhoto = FBSDKSharePhoto(image: self.GenerateMapImage("\(latitude)",lng: "\(longitude)") , userGenerated: false)
//let imageType2: FBSDKSharePhoto = FBSDKSharePhoto(image: UIImage(named: alertObj.id) , userGenerated: false)
//
imageType.caption = alertObj.alertType[0].name
let content: FBSDKShareOpenGraphContent = FBSDKShareOpenGraphContent()
let contentProp = ["og:type":"name_space:alert","og:title":"#\(name) \(addressName)","og:url" : "http://www.url.com" , "og:description": description, "place:location:latitude":"\(latitude)", "place:location:longitude":"\(longitude)", "name_space:location:latitude":"\(latitude)", "name_space:location:longitude":"\(longitude)", "og:data:name_space:location:latitude":"\(latitude)", "og:data:name_space:location:longitude":"\(longitude)", "al:web:url" : "http://www.url.com" ]
let graphObj: FBSDKShareOpenGraphObject = FBSDKShareOpenGraphObject(properties: contentProp)
graphObj.setArray([imageType], forKey: "og:image")
// graphObj.setPhoto(imageType, forKey: "og:image")
let facebookShare:FBSDKShareDialog = FBSDKShareDialog()
let fbAction: FBSDKShareOpenGraphAction = FBSDKShareOpenGraphAction()
facebookShare.delegate = alertActionsIntance
fbAction.setArray([imageType], forKey: "og:image")
fbAction.setObject(graphObj, forKey: "alert")
fbAction.actionType = "name_space:share"
content.action = fbAction
content.previewPropertyName = "alert"
facebookShare.mode = FBSDKShareDialogMode.Automatic
facebookShare.shareContent = content;
facebookShare.fromViewController = alertController;
facebookShare.show()
这也是我的应用程序配置: