Stack Overflown asked in this question:
On every repo, GitHub has a button that is labelled "Clone in Desktop" (example: https://github.com/github/developer.github.com). If you have GitHub for Mac installed, the href is something like "github-mac://openRepo/https://github.com/github/developer.github.com". This opens GitHub for Mac and offers to clone the repo. If you don't, the href is "http://mac.github.io". This is a download page for GitHub for Mac. I would like to do something similar on my website: open my app if installed and redirect to download if not. How can this be best accomplished?
The answer was about Github Conduit, but, as far as I know, Github Conduit is only for Github for Mac.
I have the same question, only for Windows operating systems. How does GitHub know whether GitHub is installed on a computer, or not?
As deepcurious said in their answer, we need to use the following code that checks if a protocol is registered:
$("a[href*='github-windows://']").click(function(e) {
var el = $(this);
setTimeout(function() {
window.location = el.data("data-href-alt");
}, 200);
// once you do the custom-uri, it should properly execute the handler, otherwise, the settimeout that you set before will kick in
window.location = el.data("href");
e.preventDefault();
});
and I have the following HTML link:
<a href="github-windows://openRepo/https://github.com/jquery/api.jqueryui.com" data-href-alt="https://www.example.com/app-not-installed">Clone in Desktop</a>
If the app is installed, Google Chrome gives me an External Protocol Request (below), so I assume it should work (although it does nothing on my computer). But, if the app is not installed, it does not go to the data-href-alt
page.
For example, if I change github-windows://
to some-uninstalled-app://
in all instances in the code, the link does nothing.
:)
– Zoolatry