Skip to content

Commit 6497fc9

Browse files
committed
Add IPC handlers for opening an app and a URL
1 parent 83e7c5a commit 6497fc9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

backend/ipc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require('fs')
22
const registerMenu = require('./menu.js')
33
const serial = require('./serial/serial.js').sharedInstance
4+
const { shell } = require('electron');
45

56
const {
67
openFolderDialog,
@@ -138,6 +139,25 @@ module.exports = function registerIPCHandlers(win, ipcMain, app, dialog) {
138139
registerMenu(win, state)
139140
})
140141

142+
ipcMain.handle('launch-app', async (event, urlScheme) => {
143+
// Launch an external app with a custom protocol
144+
return new Promise((resolve, reject) => {
145+
try {
146+
shell.openExternal(urlScheme).then(() => {
147+
resolve(true); // App opened successfully
148+
}).catch(() => {
149+
resolve(false); // App not installed
150+
});
151+
} catch (err) {
152+
reject(err);
153+
}
154+
});
155+
});
156+
157+
ipcMain.handle('open-url', async (event, url) => {
158+
shell.openExternal(url);
159+
});
160+
141161
win.on('close', (event) => {
142162
console.log('BrowserWindow', 'close')
143163
event.preventDefault()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy