[英]Share title, image and description using FBSDK for IOS
Im just start using Facebook idk for iOS and want to allow users share image,title and description from my app, something like this : 我刚刚开始为iOS使用Facebook idk,并希望允许用户从我的应用程序共享图像,标题和描述,如下所示:
But I only get the title and description :s this is my code: 但是我只得到标题和描述:这是我的代码:
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()
Also this is my app configuration: 这也是我的应用程序配置:
I had a similar issue when using FBSDKSharePhoto
. 使用
FBSDKSharePhoto
时遇到类似的问题。 If you can use a image url, just put it as an string entry into your contentProp
dictionary like "og:image":IMAGE_URL
and it will show as a thumbnail. 如果您可以使用图片网址,只需将其作为字符串条目(例如
"og:image":IMAGE_URL
放入contentProp
词典中,它将显示为缩略图。
This has worked for me 这对我有用
NSDictionary *properties = @{
@"og:type": @"",
@"og:title":@"",
@"og:description": @"",
@"og:url":@"",
@"og:image":@""
};
}
//Create an object
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
// Create an action
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = @"";
[action setObject:object forKey:@""];
// Create the content
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = @"";
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:self];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.