如何使用iPhone自定义URL方案

时间:2010-01-06 05:33:22

标签: iphone url dynamic

我有一个应用程序,我希望能够使用自定义URL方案。我希望用户能够使用自定义URL协议打开Tweetie,但我需要使用动态网站链接填充推文,我使用currentItem.link。

我发现这个代码启动Tweetie并使用静态信息填充消息:

NSString *shortened_url = @"http://your.url.com";
NSString *stringURL = [NSString stringWithFormat:@"tweetie://%@", shortened_url];
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

因此,使用上面的代码,我将如何用currentItem.link信息填充消息?

感谢。

2 个答案:

答案 0 :(得分:0)

完全取决于接收端的应用程序。你必须找出他们的协议如何工作,然后你可以按照设计使用他们的协议。

将http://协议URL添加到tweetie://协议URL的末尾不是正确的方法,并建议搜索Tweetie URL协议的工作方式。

答案 1 :(得分:0)

Tweetie protocol已被记录,但由于客户端已转换为官方Twitter版本,因此尚不清楚其中有多少仍然适用。我相信你想要的格式是:

NSString *stringURL = [NSString stringWithFormat:@"tweetie://post?message=%@", shortened_url];

我已经尝试过这个让account选择参数起作用了。基本方法有效,但帐户选择不适合我。