问题
right now I'm creating a custom tweet button for user to click it and automatically call twitter web intent to share/tweet some link. the method I'm using now is creating an anchor with href to https://twitter.com/share?url=[some url to share]
because I will use this on mobile site, is it possible to create similar href or similar link that will instead open the native app to tweet rather than opening a new tab from the browser that will open twitter website? (My goal is to make the native feeling of the tweet button from my mobile site)
any help appreciated, thanks!
回答1:
Look into iOS URL Schemes for twitter.
The twitter
scheme, for example, can be invoked with twitter://user?screen_name=lorenb
.
See this page for example, for more info.
This site attempts a more comprehensive list of iOS URL Schemes: http://wiki.akosma.com/IPhone_URL_Schemes#Twitter
回答2:
I made Tweetable to do exactly this!
https://github.com/omarish/tweetable
It tests if the app is present on the mobile device, and if so, loads the twitter:// deeplink. Else, it loads the website link if the app is not present (so it plays nice on desktop).
来源:https://stackoverflow.com/questions/16102226/link-from-html-href-to-native-app