I'm simply doing so:
if let vc = SLComposeViewController(forServiceType: SLServiceTypeTwitter) {
vc.setInitialText("Tweet text")
vc.add(image)
present(vc, animated: true)
}
I've done this in my app for a long time now and it used to work fine, but I just realized recently it doesn't work anymore. Now, only the image is being displayed, the text section is empty. So... what happened, what to do?
Try using TWTRComposer
instead of SLComposeViewController
. TwitterKit provides a lightweight TWTRComposer
with the same capabilities and encapsulates authorising users if your application doesn't have explicit log in functionality.
let vc = TWTRComposer()
vc.setText("Tweet text")
vc.setImage(UIImage(named: "hi"))
vc.setUrl(URL(string: "https://dev.twitter.com"))
vc.show(from: self, completion: nil)
You can download TwitterKit here: https://dev.twitter.com/twitterkit/ios/overview.