开发者

External Protocol Handlers and Modern Browsers

开发者 https://www.devze.com 2023-04-11 22:27 出处:网络
I\'ve noticed that GitHub launched a new \"Clone in Mac\" button a couple of months ago, which - when clicked - perform an external protocol request:

I've noticed that GitHub launched a new "Clone in Mac" button a couple of months ago, which - when clicked - perform an external protocol request:

github-mac://openRepo/REPOURL

Assuming I want to implement a similar feature for my appli开发者_StackOverflow社区cation, I wonder:

  • how do buttons degrade if the user browser doesn't support external protocols
  • how to register the protocol handler without requiring user action. In other words, how do you tell browser X to use application GitHub.app in case of protocol github-mac, without asking the user to tweak the browser settings?
  • I can see in the above URL an openRepo action, which inform the application about the action to perform. What are the common strategies/patterns to dispatch these requests for a Mac application, so that github-mac://first does something different from github-mac://second?


Browsers differ in the way they handle new protocols. Check documentation here where they have documented various Operating Systems. http://kb.mozillazine.org/Register_protocol

Its actually trivial to register a new protocol in Windows and hook it to a executable. I have done this for some apps: http://msdn.microsoft.com/en-us/library/aa767914%28v=vs.85%29.aspx

Also see register a protocol on mac osx?

0

精彩评论

暂无评论...
验证码 换一张
取 消