Please implement this in 0.13 - we are depending on this functionality, so that our app can be opened with custom url scheme - it was already on 0.12!
The code is just is just the 98b1ef8 + achwedyk@6f3ba7c
This fix is only needed for the mac - on Windows it is all ok!
On 0.12 it was implemented with https://github.com/nwjs/nw.js/pull/1769
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Testing this it very easy on any nwjs app, just follow the following few steps.
Here I will register the protocol test333://
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>Test Extension</string>
<key>CFBundleURLSchemes</key>
<array>
<string>test333</string>
</array>
</dict>
</array>
var Gui = require('nw.gui');
Gui.App.on('open', function(url) {
console.log('APP OPEN EVENT! cmd: ', url);
});
On Windows the registration process is different but it results on the same of the app being started/or activated if running and the open event fired with the url.
You can see the Windows registration process here: http://stackoverflow.com/questions/389204/how-do-i-create-my-own-url-protocol-e-g-so
Fixed in git and will be available in the next nightly build.
@rogerwang crash is fixed on beta6, but open event argument is undefined. Following @gpetrov example:
APP OPEN EVENT! cmd: undefined
Am I missing something?
@rogerwang I also don't see where this new function OSXOpenURLsHook is called ...
Very excited about getting this to work!
@k7k0 Did you got the app open event on each invocation of the custom url? Even when the app is already active? So not only when started initially?
@gpetrov I'm receiving the open event only when the app is already active. On initial launch no event is called, I'm looking for nw.App.argv arguments (that works on windows) but on OSX is not coming either.
sorry, actually beta6 doesn't contain the full fix. will fix it again asap.
@gpetrov the hook is called from here: https://github.com/nwjs/chromium.src/blob/nw13/chrome/browser/app_controller_mac.mm#L1384
Fixed again in git and will be available in the next nightly build.
@rogerwang great, now is working alright!
nw.App.argvnw.App.on('open') receives the urlThanks!
I am not getting the url on 'open' event.
This is my sample start.html:
start.txt
and package.json:
package.txt
info.plist:
Info.txt
The application gets registered with test333, but alert message never shows the url.
I tried with 0.13.0 as well as latest nwjs version.
Am I missing something?
@gpetrov Please guide me on how to get the URL. Does it take anything extra to do other than what is mentioned in your test333 example?
@snehapshinde - all works fine from the example above, you just need to handle the open event, like this in the latest nwjs:
nw.App.on('open', function(url) {
console.log('APP OPEN EVENT! cmd: ' + url);
// do something with the passed url
});
This will handle the event when user triggers the user protocol and your app is already open.
If you want to handle the case when your app is not yet open, make sure you also check the command line arguments _nw.App.argv_ for the same sort url as parameter when your app is fully initialized.
Ok, thanks. I think I was doing something wrong. It is working fine!
I have couple of questions:
Thanks for your reply.
@gpetrov Kindly reply to my queries. Waiting for it.
@snehapshinde this is not a support forum, please check the apple docs on implementing custom protocols
Ok. Thanks. I will check.
Most helpful comment
@snehapshinde - all works fine from the example above, you just need to handle the open event, like this in the latest nwjs:
This will handle the event when user triggers the user protocol and your app is already open.
If you want to handle the case when your app is not yet open, make sure you also check the command line arguments _nw.App.argv_ for the same sort url as parameter when your app is fully initialized.