April 20, 2021

Software Mile.com

Latest Software News and Hacks

Swift: Sharing image to Twitter by deeplinking into the Twitter app

Swift: Sharing image to Twitter by deeplinking into the Twitter app

I’m trying to share an image and a caption from an iOS app to Twitter without using the Twitter Kit library. Ideally, it should work exactly like the Spotify sharing I attached to this post. Any thoughts on this?

I scanned through Twitter documentation but I don’t see much in there on this topic.

I’ve also tried using Apple’s SLComposeViewController but the issue there is that images are being displayed as URLs instead of images when they appear on Twitter:

if let vc = SLComposeViewController(forServiceType: SLServiceTypeTwitter) {
                        vc.setInitialText("some caption")
                        vc.add(UIImage(named: "my_image",
                                               in: InternalConstants.bundle,
                                               compatibleWith: nil)!)
                        vc.modalPresentationStyle = .formSheet
                        nc.present(vc, animated: true)
                    }

Please don’t mark this question as a duplicate unless the solution offers instant deep linking like on the gif attached.

Thank you!

Swift: Sharing image to Twitter by deeplinking into the Twitter app


Go to Source of this post
Author Of this post: Kirill Kudaev
Title Of post: Swift: Sharing image to Twitter by deeplinking into the Twitter app
Author Link: {authorlink}