Setting up the default protocol client

Handling and defining a custom protocol is simple with the Electron. However, what if you want to make your application as the default application for specific protocols. If you want to open all the app://someurl with the application that you are developing, the app module's setAsDefaultProtocolClient should be used. This can be used in your main process to register your application with a particular protocol; this method works fine on Windows and Mac:

// In your main process
app.setAsDefaultProtocolClient('customprotocol');

// In windows you can also pass the executable path
app.setAsDefaultProtocolClient('customprotocol' 'C:Program FilesAppapp.exe');

The second parameter is optional. This will make the current executable as a default application for the customprotocol. You should not use '://' when passing the protocol name. When you click on a link with your custom protocol, the current executable will be opened, and the full URL will be sent to the application as a parameter. You can unregister the executable from handling the protocol, as follows:

app.removeAsDefaultProtocolClient('customprotocol');

The isDefaultProtocolClient method can be used to check whether the application is the default client for a protocol, as follows:

app.isDefaultProtocolClient('customprotocol');
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.87.196