Add listener in the renderer process for deeplink

Summary:
- Set userPrefferedPlugin for external deeplink
- Listen for deeplink in renderer process and navigate accordingly

Reviewed By: passy

Differential Revision: D10339035

fbshipit-source-id: 4de6249a0672f9ce02b0dfb78a4563302c308578
This commit is contained in:
Pritesh Nandgaonkar
2018-10-17 06:17:55 -07:00
committed by Facebook Github Bot
parent 4f914a655e
commit ce996ba8af
5 changed files with 91 additions and 7 deletions

View File

@@ -153,6 +153,13 @@ app.on('ready', function() {
}
});
ipcMain.on('componentDidMount', event => {
if (deeplinkURL) {
win.webContents.send('flipper-deeplink-preferred-plugin', deeplinkURL);
deeplinkURL = null;
}
});
ipcMain.on('getLaunchTime', event => {
if (launchStartTime) {
event.sender.send('getLaunchTime', launchStartTime);
@@ -161,7 +168,6 @@ ipcMain.on('getLaunchTime', event => {
launchStartTime = null;
}
});
// Define custom protocol handler. Deep linking works on packaged versions of the application!
app.setAsDefaultProtocolClient('flipper');
@@ -219,8 +225,5 @@ function tryCreateWindow() {
slashes: true,
});
win.loadURL(entryUrl);
if (deeplinkURL) {
win.webContents.send('flipper-deeplink', deeplinkURL);
}
}
}