Created
May 30, 2016 20:30
-
-
Save juliangruber/c8c1c393718d7cb34fbf05ffb2729af1 to your computer and use it in GitHub Desktop.
Here is how to accept custom protocol links like dat://LINK in an @electronjs app, in osx. For this to work you need to properly package the app into a `.app`, and place the CFBundleURLTypes spec into it's Info.plist. Then, move the app into another directory using Finder (!). Here we're using electron-packager.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<key>CFBundleURLTypes</key> | |
<array> | |
<dict> | |
<key>CFBundleURLName</key> | |
<string>Dat Link</string> | |
<key>CFBundleURLSchemes</key> | |
<array> | |
<string>dat</string> | |
</array> | |
</dict> | |
</array> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
app.on('will-finish-launching', () => { | |
app.on('open-url', (ev, url) => { | |
ev.preventDefault(); | |
// send the url to the renderer process via rpc | |
}); | |
}); | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"package": "electron-packager . --all --extend-info extend.plist" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment