Clicking a mailto:
link will open my default mail client. In a similar manner, I would like to launch an Electron app with my-app:
. What is the best way to achieve this and gracefully fallback to a standard http
link if the app isn't installed?
Furthermore, I would also like to be able to pass through some extra details my-app:foo/bar
. How would this be intercepted inside of Electron when it launches?
I have read some docs on what I think might be relevant stuff: http://electron.atom.io/docs/v0.36.0/api/protocol/ however as a frontend dev there's some gaps in my understanding of how the overarching process works. Any help much appreciated!
Electron has evolved quite a bit since this question was first posted.
You no longer have to dive quite as deep and can skip the Electron protocol API. Instead, use the app.setAsDefaultProtocolClient(protocol[, path, args])
interface and its siblings app.removeAsDefaultProtocolClient(protocol[, path, args])
and app.isDefaultProtocolClient(protocol[, path, args])
.
These enable you to register a protocol identifier your-protocol://
and receive arguments:
The whole link, including protocol, will be passed to your application as a parameter. Electron API docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With