Search code examples
iosswiftfacebook

SLComposeViewController won't set initialText for SLServiceTypeFacebook


It seems as a bug in Social framework, it won't set the initial text for Facebook service type. This is my implementation using Swift:

let view = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
if view.setInitialText("Some text") {
    NSLog("Success")
} else {
    NSLog("Failure")
}
view.addURL(NSURL(string: "https://google.ro"))
self.presentViewController(view, animated: true, completion: nil)

What it works:

  • The URL shows up for both, Facebook, and Twitter
  • The initialText works correctly just for Twitter

What is doesn't work:

  • The initialText won't show up for Facebook, even though the code above outputs "Success"

Update 2

It seems like Facebook really doesn't want developers to set the initial text of a message when Sharing as that it's impossible even with their SDK. In the app I was implementing I've chosen screenshots from the app (uploaded as images) for letting the user share their progress on Facebook.

Update

The solution is to use the Facebook SDK for iOS, that feature of Social framework is not supported by Facebook anymore.


Solution

  • Not a bug, Facebook doesn't allow it anymore.

    Use of the iOS share sheet is subject to Facebook Platform Policy, including section 2.3 which states that apps may not pre-fill. In the context of the share sheet, this means apps may not pre-fill the share sheet's initialText field with content that wasn't entered by people earlier in their use of the app.