Use will-finish-launching event to set open-url event listener

This commit is contained in:
Yuya Ochiai
2018-01-18 22:55:32 +09:00
parent 78ffa6466f
commit 71989b9c37

View File

@@ -356,14 +356,16 @@ function setDeeplinkingUrl(url) {
}
}
// Protocol handler for osx
app.on('open-url', (event, url) => {
event.preventDefault();
setDeeplinkingUrl(url);
if (mainWindow) { // 'open-url' is emitted before 'ready' when the app is launched by URL scheme.
mainWindow.webContents.send('protocol-deeplink', deeplinkingUrl);
mainWindow.show();
}
app.on('will-finish-launching', () => {
// Protocol handler for osx
app.on('open-url', (event, url) => {
event.preventDefault();
setDeeplinkingUrl(url);
if (mainWindow) { // 'open-url' is emitted before 'ready' when the app is launched by URL scheme.
mainWindow.webContents.send('protocol-deeplink', deeplinkingUrl);
mainWindow.show();
}
});
});
// This method will be called when Electron has finished