docs: updated deep link docs ()

* removed open-url listener from windows code

* updated deep-link fiddle

* fixed url hash to app.requestSingleInstanceLock

* code linted

* updated website url to relative file path

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
This commit is contained in:
Himanshu Patil 2023-01-26 12:50:10 +05:30 committed by GitHub
parent c6b9340b89
commit 8d008c977d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions
docs
fiddles/system/protocol-handler/launch-app-from-URL-in-another-app
tutorial

View file

@ -23,6 +23,8 @@ if (!gotTheLock) {
if (mainWindow.isMinimized()) mainWindow.restore()
mainWindow.focus()
}
dialog.showErrorBox('Welcome Back', `You arrived from: ${commandLine.pop().slice(0,-1)}`)
})
// Create mainWindow, load the rest of the app, etc...

View file

@ -61,7 +61,7 @@ const createWindow = () => {
In this next step, we will create our `BrowserWindow` and tell our application how to handle an event in which an external protocol is clicked.
This code will be different in Windows compared to MacOS and Linux. This is due to Windows requiring additional code in order to open the contents of the protocol link within the same Electron instance. Read more about this [here](https://www.electronjs.org/docs/api/app#apprequestsingleinstancelock).
This code will be different in Windows compared to MacOS and Linux. This is due to Windows requiring additional code in order to open the contents of the protocol link within the same Electron instance. Read more about this [here](../api/app.md#apprequestsingleinstancelockadditionaldata).
#### Windows code:
@ -77,17 +77,15 @@ if (!gotTheLock) {
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 /
dialog.showErrorBox('Welcome Back', `You arrived from: ${commandLine.pop().slice(0, -1)}`)
})
// Create mainWindow, load the rest of the app, etc...
app.whenReady().then(() => {
createWindow()
})
// Handle the protocol. In this case, we choose to show an Error Box.
app.on('open-url', (event, url) => {
dialog.showErrorBox('Welcome Back', `You arrived from: ${url}`)
})
}
```