ios - 快速发布到 Facebook 不起作用?

标签 ios facebook swift facebook-graph-api uiimage

我正在尝试将照片发布到 Facebook,使用以下代码可以正常工作:

   func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {

        self.selectedImage = info[UIImagePickerControllerOriginalImage] as! UIImage

        var photo = FBSDKSharePhoto()
        photo.image = self.selectedImage
        photo.userGenerated = true

        var content = FBSDKSharePhotoContent()
        content.photos = [photo]


        self.dismissViewControllerAnimated(true, completion: nil)

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

}

但是,这仅在用户下载了 facebook 应用程序时有效。否则它不会打开网络浏览器来分享照片,即使 facebook 声明:

The Share Dialog switches to the native Facebook for iOS app, then returns control to your app after a post is published. If someone doesn't have Facebook app installed it will automatically falls back to a web-based dialog.

有什么建议吗?感谢回答,谢谢。

最佳答案

你可以试试这个:

func postToFacebook(image: UIImage!) {
    var SocialMedia :SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
    SocialMedia.completionHandler = {
        result -> Void in
        var getResult = result as SLComposeViewControllerResult;
        switch(getResult.rawValue) {
        case SLComposeViewControllerResult.Cancelled.rawValue: println("Cancelled")
        case SLComposeViewControllerResult.Done.rawValue: println("It's Work!")
        default: println("Error!")
        }
        self.dismissViewControllerAnimated(true, completion: nil)
    }
    self.presentViewController(SocialMedia, animated: true, completion: nil)
    SocialMedia.setInitialText("...")
    SocialMedia.addImage(image)
}

关于ios - 快速发布到 Facebook 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31702300/

相关文章:

ios - 使用 Graph API 或 FQL 将所有照片包含在单个 Facebook 提要帖子中?

ios - 编辑 UITextField 时正在重置 UIScrollView

ios - 如何防止在 ios swift 中 Font Awesome 更改文本

ios - TableView 单元格描述

iphone - 一起播放 .mp3 文件的两个循环

android - 如何从我的 Flutter 应用程序控制网络缓存?

ios - Swift:如何将数据从 TableViewController 传递到 Details VC

Facebook iOS SDK 3.0 - 在 FBFriendPickerViewController 中保存并重新加载 .selection

android - 如何改造: translate element through whole screen on Android?

facebook - 如何使用 Facebook 广告 API 访问 "Saved Audiences"?