Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
457 views
in Technique[技术] by (71.8m points)

iphone - How can I open a Twitter tweet using the native Twitter app on iOS?

A tweet can be opened by Safari with a link of this format:

http://twitter.com/1Direction_X/statuses/197752514391715842

On iOS 5, Twitter is built-in. How can I open the above tweet using the native Twitter app called from my app?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is how you access other apps from your own. Just find the proper url to send for accessing status. I've included a list that should have most of the important ones. Including status finding.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"twitter://status?id=12345"]];

twitter://user?screen_name=lorenb

twitter://user?id=12345

twitter://status?id=12345

twitter://timeline

twitter://mentions

twitter://messages

twitter://list?screen_name=lorenb&slug=abcd

twitter://post?message=hello%20world

twitter://post?message=hello%20world&in_reply_to_status_id=12345

twitter://search?query=%23hashtag

Note: It can be important to make sure the user has twitter installed or this will cause a crash. So I recommend adding this in an if statement before you try to send them to twitter.

[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitter://"]];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...