Skip to content
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

setAsDefaultProtocolClient for protocol tel:// does not work at Windows 10 #14108

Closed
GeorgeTsaplin opened this issue Aug 15, 2018 · 18 comments
Closed
Projects

Comments

@GeorgeTsaplin
Copy link

GeorgeTsaplin commented Aug 15, 2018

  • Electron Version: v2.0.5
  • Operating System (Platform and Version): Windows 10
  • Last known working Electron version:

Expected Behavior
On calling url with protocol "tel://" electron application must appeare at dialog window with appropriate applications wich can handle tel protocol.

Actual behavior
On calling url with protocol "tel://" Electron application does not appeare at list of applications wich can handle tel protocol.

To Reproduce

  1. Include app.setAsDefaultProtocolClient(Protocol); at main.js;
  2. Package application for Windows;
  3. Install application from step 2 (will be run automatically after installing);
  4. Call any "tel://" url (for example from Win+R execute command "tel://1234");
$ git clone https://github.com/GeorgeTsaplin/FinesseConnector -b master
$ npm install
$ yarn install
$ yarn dist

Additional Information
Possible solution will be change SetAsDefaultProtocolClient implementation at browser_win.cc: for Windows 10 must be set such registry keys:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Classes\callto]
@="URL:callto"
"URL Protocol"=""

[HKEY_CURRENT_USER\SOFTWARE\Classes\tel]
@="URL:tel"
"URL Protocol"=""

[HKEY_CURRENT_USER\SOFTWARE\Classes\{Electron application name}.callto]

[HKEY_CURRENT_USER\SOFTWARE\Classes\{Electron application name}.callto\DefaultIcon]
@="{path to electron application exe file}"

[HKEY_CURRENT_USER\SOFTWARE\Classes\{Electron application name}.callto\shell]

[HKEY_CURRENT_USER\SOFTWARE\Classes\{Electron application name}.callto\shell\open]

[HKEY_CURRENT_USER\SOFTWARE\Classes\{Electron application name}.callto\shell\open\command]
@="\"{path to electron application exe file}" %1"

[HKEY_CURRENT_USER\SOFTWARE\{Electron application name}]

[HKEY_CURRENT_USER\SOFTWARE\{Electron application name}\Capabilities]
"ApplicationDescription"="{Electron application description}"
"ApplicationName"="{Electron application name}"

[HKEY_CURRENT_USER\SOFTWARE\{Electron application name}\Capabilities\URLAssociations]
"callto"="{Electron application name}.callto"
"tel"="{Electron application name}.callto"

[HKEY_CURRENT_USER\SOFTWARE\RegisteredApplications]
"{Electron application name}"="Software\\{Electron application name}\\Capabilities"

Also must be changed IsDefaultProtocolClient and RemoveAsDefaultProtocolClient

@welcome
Copy link

welcome bot commented Aug 15, 2018

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

@maxleverin
Copy link

Additional information:
I just tested this in Electron v.3.0.10. Issue still exists, both for tel and callto urls.

Operating System:

  • Windows 10
  • Version 1709
  • OS Build 16299.125

@Mika56
Copy link

Mika56 commented Dec 18, 2018

As a workaround, anyone wanting to register the tel protocol can use this snippet:

import {Registry} from 'rage-edit';

if(process.platform === 'win32') {

    (async () => {
        await Registry.set('HKCU\\Software\\Your app name\\Capabilities', 'ApplicationName', 'Your app name');
        await Registry.set('HKCU\\Software\\Your app name\\Capabilities', 'ApplicationDescription', 'Your app name');

        await Registry.set('HKCU\\Software\\Your app name\\Capabilities\\URLAssociations', 'tel', 'Your app name.tel');

        await Registry.set('HKCU\\Software\\Classes\\Your app name.tel\\DefaultIcon', '', process.execPath);

        await Registry.set('HKCU\\Software\\Classes\\Your app name.tel\\shell\\open\\command', '', `"${process.execPath}" "%1"`);

        await Registry.set('HKCU\\Software\\RegisteredApplications', 'Your app name', 'Software\\Your app name\\Capabilities');
    })();
}

The registration is per user, so you need to execute this code for every user. You can execute it at every launch of your app, it won't do any harm.
This won't prevent you from building on Linux or macOS, rage-edit uses the reg command, and a such is not a native dependency.

@clusterberries
Copy link

Hello!
Thank you for workaround for Windows 10.

I found out a case when tel: protocol cannot be used on Windows 7. If there is no default application for tel: protocol, I can register my own application and it works perfect. But if there is another program already registered, my application isn't even displayed in the list of available applications.
Maybe somebody know what are the registry keys that should be added to display my application in the list for tel: protocol?

@sofianguy
Copy link
Contributor

Thank you for taking the time to report this issue and helping to make Electron better.

The version of Electron you reported this on has been superseded by newer releases.

If you're still experiencing this issue in Electron v4.2.x or later, please add a comment specifying the version you're testing with and any other new information that a maintainer trying to reproduce the issue should know.

I'm setting the blocked/need-info label for the above reasons. This issue will be closed 7 days from now if there is no response.

Thanks in advance! Your help is appreciated.

@sofianguy sofianguy added the blocked/need-info ❌ Cannot proceed without more information label Aug 9, 2019
@clusterberries
Copy link

@sofianguy the issue for Windows 7 I described in the last comment is reproduced on 5.0.2. I guess issue for Windows 10 is reproduced on the same version. I'll check it today.

@clusterberries
Copy link

The issue is reproduced with Electron 5.0.2 on Windows 10

@sofianguy sofianguy added 5-0-x and removed blocked/need-info ❌ Cannot proceed without more information labels Aug 13, 2019
@sofianguy sofianguy added this to Unsorted Issues in 5.0.x Aug 13, 2019
@joeyer
Copy link

joeyer commented Nov 11, 2019

@clusterberries Is there a solution for win7?

@joeyer
Copy link

joeyer commented Nov 13, 2019

As a workaround, anyone wanting to register the tel protocol in window 7 can use this snippet:

import {Registry} from 'rage-edit';
(async () => {
await Registry.set('HKCR\Your app name', '', Your app name);
await Registry.set('HKCR\Your app name\DefaultIcon', '', "${process.execPath}" "%1");
await Registry.set('HKCR\Your app name\shell\open\command', '', "${process.execPath}" "%1");
await Registry.set('HKCR\tel', '', 'Your app name');
await Registry.set('HKCR\tel\DefaultIcon', '', process.execPath);
await Registry.set('HKCR\tel\shell\open\command', '', "${process.execPath}" "%1");

    await Registry.set('HKLM\\SOFTWARE\\Classes\\Your app name', '', 'Your app name');
    await Registry.set('HKLM\\SOFTWARE\\Classes\\Your app name\\DefaultIcon', '', process.execPath);
    await Registry.set('HKLM\\SOFTWARE\\Classes\\Your app name\\shell\\open\\command', '', `"${process.execPath}" "%1"`);
    await Registry.set('HKLM\\SOFTWARE\\Classes\\tel', '', 'Your app name');
    await Registry.set('HKLM\\SOFTWARE\\Classes\\tel\\DefaultIcon', '', process.execPath);
    await Registry.set('HKLM\\SOFTWARE\\Classes\\tel\\shell\\open\\command', '', `"${process.execPath}" "%1"`);
})();

@clusterberries
Copy link

@joeyer I tried to find solution for windows 7, I tried to set keys to HKLM, but it requires admin rights. My application doesn't have admin rights, so it is not an appropriate solution for me.

@electron-triage
Copy link

Thank you for taking the time to report this issue and helping to make Electron better.

The version of Electron you reported this on has been superseded by newer releases.

If you're still experiencing this issue in Electron 6.x.y or later, please add a comment specifying the version you're testing with and any other new information that a maintainer trying to reproduce the issue should know.

I'm setting the blocked/need-info label for the above reasons. This issue will be closed 7 days from now if there is no response.

Thanks in advance! Your help is appreciated.

@electron-triage electron-triage added the blocked/need-info ❌ Cannot proceed without more information label Feb 19, 2020
@electron-triage
Copy link

Thank you for your issue!

We haven't gotten a response to our questions in our comment above. With only the information that is currently in the issue, we don't have enough information to take action. I'm going to close this but don't hesitate to reach out if you have or find the answers we need, we'll be happy to reopen the issue.

@N4COM
Copy link

N4COM commented Feb 23, 2022

Hi, I'm using electron 15.0.0 with Windows 10. The method seems not work. I tried with "tel", "callto" and with a custom protocol but it works only with my custom protocol. The app is not registered for the protocol I specify, so when I call the url, the app won't be opened. Also app can't be registered as default app manually, so the problem is that the method doesn't register the app for handling protocol.

My code is very simple:

const protocol = "tel"; //or "callto" or "customprotocol"
app.setAsDefaultProtocolClient(protocol);

Is there some log I can activate in order to investigate it? Should I manually write the keys into register?

@gr33k
Copy link

gr33k commented Feb 23, 2022

Found this when searching for a solution to #22565 - The best are workarounds which require admin privileges for your application (not even sure how well they work in windows 7,8,10 let alone 11). Do the Electron SDK devs anticipate this will ever be fixed? If so, do we have ETA please?

@PeteAUK
Copy link

PeteAUK commented Feb 3, 2023

This appears to still be an issue in that it's not possible to use app.setAsDefaultProtocolClient('tel') to register the application so that it appears within the Windows list of applications. Don't really want to hook up a registry hack for this. Please could this issue be reopened and investigated.

Running ElectronJS v22.2.0 on a Windows 10 PC. I've also got local administrator rights, although the end user may not.

@thanhle7
Copy link

Not making any sense. Setting default app for some type of document requires some admin privileges. How to could we make it possible from an user's app.

@PeteAUK
Copy link

PeteAUK commented Aug 15, 2023

Not making any sense. Setting default app for some type of document requires some admin privileges. How to could we make it possible from an user's app.

Pretty sure the handler for the tel protocol doesn't require admin privileges to set in Windows in the same way as setting the default handler for a .doc file doesn't because it should be being set at a user level, not machine. The whole point (and this issue is closed btw) is that the setAsDefaultProtocolClient doesn't work

@galletafromjell666
Copy link

This issue has been present for a while, I do not think it will be solved in a near future since Windows uses a hash to validate the protocol association (at least it has been reverse engineered, link).

You can check the registry entry for the association here:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\tel\UserChoice

To have a similar experience as setAsDefaultProtocolClient you could include a flow like:
1 - Register the app using this workaround. Alternatively, you can use electron-builder and a custom NSIS.
2 - Remove the current protocol association:

const { Registry } = require('rage-edit');

await Registry.delete('HKCU\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\tel\\UserChoice');

3 - Make the association modal appear with:

const { shell } = require('electron');

shell.openExternal('tel:');

You can tweak the flow checking if your app is currently the protocol handler:

const myAppName = 'your-app-name'
const protocol = 'tel'
const registryAppName = await Registry.get(
      `HKCU\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\${protocol}\\UserChoice`,
      'ProgId'
    );

const associatedAppName = registryAppName.replace(`.${protocol}`, '');
const isMyAppAssociated = associatedAppName === myAppName 

Please do not forget to remove your entries from the Windows Registry when your app is being uninstalled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
5.0.x
Unsorted Issues
Development

No branches or pull requests