我刚刚开始在iOS上使用Facebook idk,并希望允许用户从我的应用中分享图片,标题和说明,如下所示:
但我只得到标题和描述:这是我的代码:
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()
这也是我的应用配置:
答案 0 :(得分:0)
使用FBSDKSharePhoto
时遇到了类似的问题。如果您可以使用图片网址,只需将其作为字符串条目添加到contentProp
字典中,如"og:image":IMAGE_URL
,它就会显示为缩略图。
这对我有用
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];