SLComposeViewController won't set initialText for SLServiceTypeFacebook

萝らか妹 提交于 2019-12-03 16:07:15

问题


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.


回答1:


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.




回答2:


Facebook dose't allow to pre fill message anymore. For more info here

Saying that, if you use native Facebook sdk it won't solve your problem, because Facebook will not publish your app. So as written on Facebook guidelines, the only solutions that you have are:

  1. Populate the user message parameter with content that the user manually entered earlier in your app's flow.
  2. Your app’s composer can include a call-to-action that disappears when people start to write a post. For example, Facebook's composer uses grey scale text to ask “What's on your mind?” that disappears when people start to write.



回答3:


I think it is an iOs 8.3 bug. Before I updated to that version it was working correctly. :-(



来源:https://stackoverflow.com/questions/29870514/slcomposeviewcontroller-wont-set-initialtext-for-slservicetypefacebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!