[英]Facebook sharing images from an iOS app
I am having an issue with sharing an image on Facebook, from an iOS app. 我在通过iOS应用程序在Facebook上共享图像时遇到问题。 ( See this post ) I read that it was against Facebook policy to prefill text before sharing. ( 请参阅这篇文章 )我读到在共享之前先填充文本是违反Facebook政策的。 Is it also contrary to their policy to prefill an image? 预填充图像是否也违反他们的政策?
I can understand that prefilling can lead to possible exagerations. 我可以理解,预填充可能导致费用高涨。 But in an app dealing with pictures, if I cannot make it easy for the user to share his picture by preloading it; 但是在一个处理图片的应用程序中,如果我不能通过预加载使用户轻松共享他的图片,那么, what could be the point of having a FB button in my app? 在我的应用程序中使用FB按钮有什么意义?
As my understanding, we can't prefill text, however, can share photos from your application to Facebook and there is no restriction of that. 据我了解,我们无法预填充文本,但是可以将您的应用程序中的照片共享到Facebook,并且对此没有限制。 As they said, there are just some requirements 正如他们所说,只有一些要求
Here is the example code of using FBSDKSharePhotoContent to share photos via FB 这是使用FBSDKSharePhotoContent通过FB共享照片的示例代码
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = info[UIImagePickerControllerOriginalImage];
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = image;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[photo];
...
}
Reference: https://developers.facebook.com/docs/sharing/ios 参考: https : //developers.facebook.com/docs/sharing/ios
I also try to find out how to share a image to Facebook and their documentation didn't help me a lot -> https://developers.facebook.com/docs/swift/sharing/content-types/ 我还尝试找出如何与Facebook分享图片,而他们的文档对我没有太大帮助-> https://developers.facebook.com/docs/swift/sharing/content-types/
In the end I manage to do it in this way: 最后,我设法以这种方式做到这一点:
import FBSDKCoreKit
import FBSDKLoginKit
import FBSDKShareKit
private func shareInFacebook() {
let photo = SharePhoto(image: image!, userGenerated: true)
let content = SharePhotoContent()
content.photos = [photo]
let showDialog = ShareDialog(fromViewController: self, content: content, delegate: self)
if (showDialog.canShow) {
showDialog.show()
} else {
self.view.makeToast("It looks like you don't have the Facebook mobile app on your phone.")
}
}
Hope this will help someone ;) 希望这会帮助某人;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.