link from HTML href to native app

半城伤御伤魂 提交于 2020-01-04 13:43:29

问题


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

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