You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deep can launch user local Neuron wallet without it already started. If Neuron not run on the user's PC, it will launch it first and receive the wallet connect URL.
The implement of deep link
There are two necessary steps, register and listen.
Register deep link
On the Neuron, we should invoke these code when its main process start.
The method setAsDefaultProtocolClient sets the current executable as the default handler for a protocol (aka URI scheme).
Extra works on MacOS and Linux
On MacOS, all registered URL scheme should be declared beforehand in MacOS Info.plist.
Meanwhile, on Linux, the linux desktop file for the app should include new protocol handler.
By using electron-builder, These build config options should be added.
protocols:
name: 'Neuron'# Don't forget to set `MimeType: "x-scheme-handler/deeplink"` for `linux.desktop` entry!schemes: ['neuron']# other configlinux:
desktop:
MimeType: "x-scheme-handler/deeplink"
response deep link
Previous step allows DApp to wake neuron and send the Wallet Connect URL, this step is for handling it.
functionresponseDeepLink(event: Electron.Event,url: string){console.log(url)}app.on('open-url',responseDeepLink)if(process.os==='win32'){constgotTheLock=app.requestSingleInstanceLock()if(!gotTheLock){app.quit()}else{app.on('second-instance',(event,commandLine,workingDirectory)=>{// Someone tried to run a second instance, we should focus our window.if(mainWindow){if(mainWindow.isMinimized())mainWindow.restore()mainWindow.focus()}// the commandLine is array of strings in which last element is deep link url// the url str ends with /responseDeeplink(event,commandLine.pop().slice(0,-1)!)})}}
On DApp
On the Dapp, just use a html <a> label, or use window.open can pass the wallet connect url to Neuron.
On Windows platfrom, process.defaultApp will return undefined when application is packed. In electron official document, it has a if clause before call app.setDefaultProtocolClient.
TL;DR
Deep can launch user local Neuron wallet without it already started. If Neuron not run on the user's PC, it will launch it first and receive the wallet connect URL.
The implement of deep link
There are two necessary steps, register and listen.
Register deep link
On the Neuron, we should invoke these code when its main process start.
The method
setAsDefaultProtocolClient
sets the current executable as the default handler for a protocol (aka URI scheme).Extra works on MacOS and Linux
On MacOS, all registered URL scheme should be declared beforehand in MacOS
Info.plist
.Meanwhile, on Linux, the linux desktop file for the app should include new protocol handler.
By using electron-builder, These build config options should be added.
response deep link
Previous step allows DApp to wake neuron and send the Wallet Connect URL, this step is for handling it.
On DApp
On the Dapp, just use a html
<a>
label, or usewindow.open
can pass the wallet connect url to Neuron.Known bug
On Windows platfrom,
process.defaultApp
will returnundefined
when application is packed. In electron official document, it has a if clause before callapp.setDefaultProtocolClient
.The text was updated successfully, but these errors were encountered: