-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: API for registering node-webkit applications as protocol handlers [$50] #951
Comments
+1 I would very much like that feature as well. |
For MacOS X you can already do this, statically, just modifying the info.plist in your customised node-webkit app: http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html The page describes the iPhone, but this works on the Mac as well. For an example, take a look at /Applications/Utilities/Terminal.app/Contents/Info.plist Is this an acceptable solution on the Mac side? Do we need something more dynamic? Does anyone know if other operating system offer an equivalent approach? Just did a bit more reading:
|
I think this way passing data to your application won't be possible without node-webkit changes to accept them and forward them to your application which is the true power of those urls |
👍 |
For the moment a solution could be provided to people who want to take node-webkit and 'rebrand' for easier distribution of their solution. I am going to explain this from a Mac perspective, since that's what I have in front of me, in terms of documentation:
At the very least this would offer a prototype for future work? It may be worth starting this as a general node package module and then making a node-webkit specific version once the other issues have been worked out? |
This sounds very interesting and useful, but as some of you already pointed out, you want to be able to pass in variables in those URLs. Has anything more happened since this thread was last active? |
protocol handlers very very useful in html5 apps. I want this feature |
This can be done with the following in /src/browser/app_controller_mac.mm -(void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:self
andSelector:@selector(handleGetURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass andEventID:kAEGetURL];
}
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
NSString *url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
if (content::Shell::windows().size() == 0) {
CommandLine::ForCurrentProcess()->AppendArg([url UTF8String]);
CommandLine::ForCurrentProcess()->FixOrigArgv4Finder([url UTF8String]);
return;
}
// Just pick a shell and get its package.
nw::Package* package = content::Shell::windows()[0]->GetPackage();
if (package->self_extract()) {
// Let the app deal with the opening event if it's a standalone app.
nwapi::App::EmitOpenEvent([url UTF8String]);
} else {
// Or open a new app in the runtime mode.
}
} |
👍 |
@shokurov why don't you make a pull request our of this? |
If only I can redirect a path request to a DB query that returns something, with a protocol handler |
Sorry guys, have no time to make a pull request, please do whomever has a minute |
👍 |
+1 Great feature |
+1 |
+1 this would be very useful! |
This is default OSX way of registering protocol handlers implemented
Mac solution is posted as pull request #2429 |
@shokurov that's great news! Thanks a lot for it! |
+1 very much needed ! |
@rogerwang is there any information about release date for this feature? |
@rogerwang there is already a pull request for it, you just need to accept it: #1769 we really need this |
Any update on this one? |
is this supposed to be in v0.12.0-alpha3? I just tested on mac, and it still seems that gui.App.argv is not populated, unlike on windows, where this works correctly |
This feature seems to have been nuked :( |
bumping |
Seeing how this is possible with an NPM it isn't too crazy to think someone can create a cross platform version of this NPM package. Of course I would drop edge.js and use a better method of accessing the registry to avoid needing the .NET framework. |
Then, I guess, I'll close this issue when someone creates such a package. |
It would be a nice feature to have. Doing a quick look on Linux and Mac instructions it seems it would only be a matter of creating or packaging some files with your app/protocol info and possibly doing some shell commands to put them in their proper places. I don't have the time/need to make this so I am going to post the ingredients here: |
What is the latest version that still has support for this? |
I would love to have this as well. Any chance to get this in a future version ? |
I've tested various versions from http://dl.nwjs.io/. These were: 0.11.6, 0.11.7-rc1, 0.11.7-rc2, 0.12.0-alpha3 and 0.12.0-rc1 - none of them had this functionality working. |
I think it's more of a build tool / packager issue. Each build tool does these processes different. Experiment Further Windows Issues Just deleted my previously compiled and installed app. Still have the protocol bindings in OS, although the behaviour is the same as before adding the custom protocol. Should look into whether how to remove them. Note: used this to check protocols |
@renarsvilnis you say
But the real problem on Mac is that currently there is no way for nw.js app to differentiate between |
Could you please upload the binary with the fix on a new repo and give a link? You would save me (at least) a headache.. |
@jaruba I've done exactly as you've suggested. Here is the repo: https://github.com/achwedyk/nw.js-release |
@achwedyk Awesome! One question though, why did you build it for 32bit? It would of been safe (and recommended) to build it for 64bit architecture as all OSX are 64bit anyway. :) |
It's nice feature to open application from external source on Mac such as browser. Could you please provide us on which version of node-webkit, we can use this feature on windows? |
this already works on windows with all versions of nw-js. This requires windows registry entries, and has nothing to do with nw.js here is an extract from my wix installer configuration
|
Anybody still working on this issue(specially for Mac)? |
These two months of silence are most likely to say “nope”. |
actually this is already implemented some time ago, for usage see: #4240 (comment) maybe somebody should document it |
@rororofff has funded $2.00 to this issue.
|
This feature already works on all platforms.
On Linux, just set up your .desktop file:
You can now access the URL with: console.log(nw.App.argv); I'd like to write proper documentation in |
It would be nice if this could all be handled in an easy to use Node module with a simple API. I've created a repo with some documentation on the existing suggested solutions. This can be a place to submit PR's against for each OS. I need help from others though to get the library working. This is a very low priority for me, as I don't have a need for this functionality in my apps. But happy to maintain the library, merge PR's, test the functionality, and do releases. |
Now There is a nm module to do this which supports macOS, windows and Linux as of now. const path = require('path');
const ProtocolRegistry = require('protocol-registry');
console.log('Registering...');
// Registers the Protocol
ProtocolRegistry.register({
protocol: 'testproto', // sets protocol for your command , testproto://**
command: `node ${path.join(__dirname, './index.js')} $_URL_`, // this will be executed with a extra argument %url from which it was initiated
override: true, // Use this with caution as it will destroy all previous Registrations on this protocol
terminal: true, // Use this to run your command inside a terminal
script: false
}).then(async () => {
console.log('Successfully registered');
}); You can read more about it here : https://www.npmjs.com/package/protocol-registry This module is not exactly related to nwjs but you can achieve similar results with this workaround. |
Something like
navigator.registerProtocolHandler()
, but for node-webkit's applications.The expected result is that the application is registered as a system-wide handler for the given protocol, i.e. is launched from the command line by the following:
open protocol://...
start "" protocol://...
xdg-open protocol://...
Bonus feature request: an API to check if an application is already registered as a handler for the given protocol.
There is a $50 open bounty on this issue. Add to the bounty at Bountysource.
The text was updated successfully, but these errors were encountered: