【问题标题】:How to share image with text in Facebook SDK in swift如何在 Facebook SDK 中快速共享图像和文本
【发布时间】:2019-02-14 14:49:49
【问题描述】:

我想在 facebook 上分享带有图片和文字的帖子。我正在使用 Facebook SDK 并且可以共享图像,现在我想与此图像共享文本。怎么办?

这里是分享图片的源代码,

 let photo:FBSDKSharePhoto = FBSDKSharePhoto()

    var message:String?

    let imageName:String = "Star.png"
    photo.image = UIImage(named: imageName)
    photo.isUserGenerated = true

    let content = FBSDKSharePhotoContent()
    content.photos = [photo];


    let dialog = FBSDKShareDialog()
    dialog.fromViewController = self
    dialog.shareContent = content
    dialog.mode = .native
    dialog.show()

【问题讨论】:

    标签: ios swift facebook


    【解决方案1】:

    由于某些应用程序的滥用,Facebook 通过简单地忽略它来明确禁用文本的预填充选项。

    “您不得预先填写与 以下产品,除非用户手动生成内容 工作流程的早期:流故事(user_message 参数 Facebook.streamPublish 和 FB.Connect.streamPublish,以及消息 stream.publish 的参数),照片(标题),视频(描述), 注释(标题和内容)、链接(评论)和 Jabber/XMPP。”

    更多信息here

    【讨论】:

      【解决方案2】:

      Facebook 不允许用户在图片中添加文字。

      集成 facebookshare sdk

      @IBAction func facebookBtn(sender: AnyObject) {
        let shareImage = SharePhoto()
        shareImage.image = imageView.image //Image from your imageview
        shareImage.isUserGenerated = true
      
        let content = SharePhotoContent()
        content.photos = [shareImage]
      
        let sharedDialoge = ShareDialog()
        sharedDialoge.shareContent = content
      
        sharedDialoge.fromViewController = self
        sharedDialoge.mode = .automatic
      
      
        if(sharedDialoge.canShow)
        {
          sharedDialoge.show()
        }
        else
        {
          print("Install Facebook client app to share image")
        }
      }
      

      【讨论】:

        【解决方案3】:

        试试这个:

         let sharePhoto = FBSDKSharePhoto()
        photo.image = photo
        photo.caption = "you title"
        
        let content = FBSDKShareMediaContent()
        content.media = [photo];
        

        【讨论】:

        • 您不能代替用户预先填写照片说明。用户应根据 Facebook 平台政策 (2.3) 执行此操作。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-19
        • 2017-11-13
        • 1970-01-01
        相关资源
        最近更新 更多