0

I am trying to implement the Facebook Share in my quiz app. The content is app store link and quiz score.Which is working fine in simulator but in device shows in different and not showing my description. Here is my Code

    func ShareFB() {
    let fbVC = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
    fbVC?.setInitialText("Hey! I scored \(String(describing: UserDefaults.standard.string(forKey: "TOTAL_SCORE")!)) in Test. This is really interesting! You can also try.")
    fbVC?.add(URL(string: "https://itunes.apple.com/us/app/test-app/i?ls=1&mt=8"))
    fbVC?.add(UIImage(named: "AppIcon"))
    present(fbVC!, animated: true) { _ in

    }
}

also attaching screen Shot of simulator and device. Screenshot of Simulator

Screenshot of device

Asd_123
  • 53
  • 8

3 Answers3

0

Why don't you use UIActivityController for such functionality?

Example:

    let shareItems = [
        "Hey! I scored \(String(describing: UserDefaults.standard.string(forKey: "TOTAL_SCORE")!)) in Test. This is really interesting! You can also try.",
        URL(string: "https://itunes.apple.com/us/app/test-app/i?ls=1&mt=8"),
        UIImage(named: "AppIcon")] //Add the items you want to share in this array

    let activityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil)

    self.present(activityViewController, animated: true, completion: nil)

Edit:

Check this out: https://stackoverflow.com/a/30020929/5716829

PGDev
  • 23,751
  • 6
  • 34
  • 88
0

now you cannot share image, text and url simultaneously in facebook. also Facebook does not allow pre filled text now

Amal T S
  • 3,327
  • 2
  • 24
  • 57
  • ok but i want to know one more thing, in game applications how they share the highest scores ? thanks for your answer – Asd_123 Aug 08 '17 at 07:11
  • 1
    They either use the Scores/Achievements API, or they create individual URLs for each result that serve the right OG meta data to show the result in title/description/thumbnail ... – CBroe Aug 08 '17 at 07:21
0

According to Facebook's 2.3 policy rules, you can't share pre-filled content because of policy violation. Facebook does not allow you to share the pre-filled user message parameters with any content the user didn't entered himself.

If you want to share content on Facebook then user has to write/enter himself in Facebook prompt message dialog.

For more info, please visit: https://developers.facebook.com/docs/apps/review/prefill

Inder Jagdeo
  • 229
  • 2
  • 9