electron-react-boilerplate / electron-react-boilerplate/electron-react-boilerplate

Custom Protocol for Deep Link no working in Development

Closed
#3,245 24 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
TypeScript
Stars
24.3k
Forks
4k
Avg merge
20m
Merged PRs (30d)
4

Description

Hello, I'm created custom protocol for deep link.
code is like bottom.

src/main/main.ts
```ts
app.removeAsDefaultProtocolClient('customtest');

if (process.defaultApp) {
console.log(process.execPath);
console.log(process.argv);
if (process.env.NODE_ENV === 'development' && process.platform === 'win32') {
app.setAsDefaultProtocolClient('customtest', process.execPath, [
process.argv[1],
path.resolve(process.argv[2]),
process.argv[3],
path.join(
__dirname,
'..',
'..',
'node_modules',
'ts-node',
'register',
'transpile-only.js'
),
path.resolve(process.argv[5]),
]);
} else if (process.platform === 'win32') {
app.setAsDefaultProtocolClient('customtest', process.execPath, []);
} else {
app.setAsDefaultProtocolClient('customtest');
}
} else {
app.setAsDefaultProtocolClient('pixellauncher', process.execPath);
}

const gotTheLock = app.requestSingleInstanceLock();

(skip)

app.on('open-url', (event, url) => {
dialog.showErrorBox('Welcome Back', `You arrived from: ${url}`);
});
```

![image](https://user-images.githubusercontent.com/56160437/174699599-20b49661-1362-4720-a0c9-f87b967d57a8.png)
When I package the app, it's working well. but run development with `npm run start`, then it cause the error "unable to parse" like this.

```
[
'C:\\Users\\tilto\\Documents\\git-projects\\***\\node_modules\\electron\\dist\\electron.exe',
'--require',
'C:\\Users\\tilto\\Documents\\git-projects\\***\\node_modules\\electronmon\\src\\hook.js',
'-r',
'ts-node/register/transpile-only',
'.'
]
```
I checked process argument like this.
so this is protocol set in development.
```ts
app.setAsDefaultProtocolClient('customtest', process.execPath, [
process.argv[1],
path.resolve(process.argv[2]),
process.argv[3],
path.join(
__dirname,
'..',
'..',
'node_modules',
'ts-node',
'register',
'transpile-only.js'
),
path.resolve(process.argv[5]),
]);
```

How can I get Custom Protocol for Deep Link to work in Development in Electron React Boilerplate?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.