app.setAsDefaultProtocolClient(protocol[, path, args])
djcas9 opened this issue · comments
Doc: https://www.electronjs.org/docs/latest/api/app#appsetasdefaultprotocolclientprotocol-path-args
How could I go about adding support for something like this?
You'll need to modify both go and JS projects.
Regarding the JS project, here's what you need to do:
- add
appCmdSetAsDefaultProtocolClient and
appEventSetAsDefaultProtocolClient` here - add a
case
statement here listening forappCmdSetAsDefaultProtocolClient
, executeapp.setAsDefaultProtocolClient
with the args provided in thejson
object, and return the boolean result of the function in aappEventSetAsDefaultProtocolClient
event using asuccess
json key
In the go project:
- add the following attributes here:
Protocol string
Args []string
Success *bool
- add
appCmdSetAsDefaultProtocolClient
andappEventSetAsDefaultProtocolClient
here - add a
(a *Astilectron) SetAsDefaultProtocolClient(protocol, path string, args []string) error
method that will do this:
var e Event
if e, err = synchronousEvent(a.worker.Context(), a, a.writer, Event{Name: appCmdSetAsDefaultProtocolClient, Protocol: protocol, Path: path, Args: args}, appEventSetAsDefaultProtocolClient); err != nil {
// TODO Process error the same way this package handle errors
return
}
if !e.Success {
//return an error as well
}
Let me know if there is anything strange you would like changed, modified, etc.
One aspect I am not sure fits the model you have built (and maybe there is a more general approach). Specifically capturing open-url
in the way I did.
It feels like there should be a way to achieve the same thing from go-astilectron w/o needing to modify astilectron but I didn't see anything (or didn't look hard enough).