I basically want the user to share something from my app to twitter. I was exploring the different methods possible and found SLComposeViewController but it is deprecated. Support for twitterKit has also been officially stopped by twitter. One possible way to do so seems to be like given in the answers in this post. Is there some other better way to do so? I would prefer if the user stays in the app itself (something similar to sharesheet for fb). Thanks!
Asked
Active
Viewed 6,208 times
1 Answers
2
You can use twitter-kit-ios.
For posting a tweet sample code from documentation would be following
Objective-c
// Objective-C
TWTRComposer *composer = [[TWTRComposer alloc] init];
[composer setText:@"just setting up my Twitter Kit"];
[composer setImage:[UIImage imageNamed:@"twitterkit"]];
// Called from a UIViewController
[composer showFromViewController:self completion:^(TWTRComposerResult result) {
if (result == TWTRComposerResultCancelled) {
NSLog(@"Tweet composition cancelled");
}
else {
NSLog(@"Sending Tweet!");
}
}];
Swift
// Swift
let composer = TWTRComposer()
composer.setText("just setting up my Twitter Kit")
composer.setImage(UIImage(named: "twitterkit"))
// Called from a UIViewController
composer.show(from: self.navigationController!) { (result in
if (result == .done) {
print("Successfully composed Tweet")
} else {
print("Cancelled composing")
}
}
Straight from the discontinuing blog post you can use, new api endpoints.

Ratul Sharker
- 7,484
- 4
- 35
- 44
-
3Actually I was looking for an alternative to twitter-kit-ios since twitter has stopped support for it and so I would prefer not to use it! – Priyanshu Goyal Nov 14 '18 at 12:35
-
Thanks for the time. I ended up using openurl finally since for standard api, user authentication would have been needed from the app and i didn't want user to login via twitter on the app. – Priyanshu Goyal Nov 18 '18 at 16:48
-
@PriyanshuGoyal which endpoint you have used for sharing a link via App. – Manish Nahar Sep 27 '19 at 11:58
-
Can you also include the code in Objective-C? – Erika Electra Apr 02 '21 at 09:56
-
Anything else twitter-kit-ios is now deprecated. – Jigar Fumakiya Aug 06 '21 at 05:20