diff --git a/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/index.html b/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/index.html index 1c89c4ce49b1..a3ddd1b933fc 100644 --- a/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/index.html +++ b/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/index.html @@ -1,92 +1,81 @@ -
- -app
module provides methods for handling protocols.These methods allow you to set and unset the protocols your app should be the default app for. Similar to when a browser asks to be your default for viewing web pages.
+Open the full app API documentation(opens in new window) in your browser.
-The protocol API allows us to register a custom protocol and intercept existing protocol requests.
+These methods allow you to set and unset the protocols your app should be the default app for. Similar to when a + browser asks to be your default for viewing web pages.
-You can set your app as the default app to open for a specific protocol. For instance, in this demo we set this app as the default for electron-api-demos://
. The demo button above will launch a page in your default browser with a link. Click that link and it will re-launch this app.
This feature will only work on macOS when your app is packaged. It will not work when you're launching it in development from the command-line. When you package your app you'll need to make sure the macOS plist
for the app is updated to include the new protocol handler. If you're using electron-packager
then you can add the flag --extend-info
with a path to the plist
you've created. The one for this app is below.
- const {shell} = require('electron')
- const path = require('path')
- const protocolHandlerBtn = document.getElementById('protocol-handler')
- protocolHandlerBtn.addEventListener('click', () => {
- const pageDirectory = __dirname.replace('app.asar', 'app.asar.unpacked')
- const pagePath = path.join('file://', pageDirectory, '../../sections/system/protocol-link.html')
- shell.openExternal(pagePath)
- })
-
-
- const {app, dialog} = require('electron')
- const path = require('path')
+ Open the full protocol API documentation in your
+ browser.
- if (process.defaultApp) {
- if (process.argv.length >= 2) {
- app.setAsDefaultProtocolClient('electron-api-demos', process.execPath, [path.resolve(process.argv[1])])
- }
- } else {
- app.setAsDefaultProtocolClient('electron-api-demos')
- }
+ -----
- app.on('open-url', (event, url) => {
- dialog.showErrorBox('Welcome Back', `You arrived from: ${url}`)
- })
+ Demo
+
+ First: Launch current page in browser
+
+
-
-
-
-
-
-
- CFBundleURLTypes
-
-
- CFBundleURLSchemes
-
- electron-api-demos
-
- CFBundleURLName
- Electron API Demos Protocol
-
-
- ElectronTeamID
- VEKTX9H2N7
-
-
-
-
- + Then: Launch the app from a web link! + Click here to launch the app +
+ + ---- + +You can set your app as the default app to open for a specific protocol. For instance, in this demo we set this app
+ as the default for electron-fiddle://
. The demo button above will launch a page in your default
+ browser with a link. Click that link and it will re-launch this app.
This feature will only work on macOS when your app is packaged. It will not work when you're launching it in
+ development from the command-line. When you package your app you'll need to make sure the macOS plist
+ for the app is updated to include the new protocol handler. If you're using electron-packager
then you
+ can add the flag --extend-info
with a path to the plist
you've created. The one for this
+ app is below:
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+ <plist version="1.0">
+ <dict>
+ <key>CFBundleURLTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>electron-api-demos</string>
+ </array>
+ <key>CFBundleURLName</key>
+ <string>Electron API Demos Protocol</string>
+ </dict>
+ </array>
+ <key>ElectronTeamID</key>
+ <string>VEKTX9H2N7</string>
+ </dict>
+ </plist>
+
+
+ + + + - -