How to use iPhone Custom URL schemes

穿精又带淫゛_ 提交于 2019-12-11 14:00:28

问题


I've got an app that I want to be able to use Custom URL schemes for. I want users to be able to open Tweetie using the Custom URL protocol however I need to populate the tweet with dynamic website link which I get using currentItem.link.

I found this code which launches Tweetie and populates a message with static information:

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

So using the above code how would I populate the message with currentItem.link information?

Thanks.


回答1:


It depends entirely on the application on the receiving end. You have to find out how their protocol works, then you can use their protocol as it is designed.

Adding a http:// protocol URL to the end of a tweetie:// protocol URL is not the correct method, and searching for how the Tweetie URL protocol works would be suggested.




回答2:


The Tweetie protocol is documented, but it's not clear how much of this still applies since the client was converted to the official Twitter one. I believe that the format you want is:

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

I have already tried this to get the account selection parameter to work. The basic method works, but account selection does not for me.



来源:https://stackoverflow.com/questions/2011139/how-to-use-iphone-custom-url-schemes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!