windows - How to register electron app for 'tel' protocol at the time of installation? - Stack Overflow

Electron version 30Using Electron builder (25.0.0-alpha.9)At the time of installation, I want my app to

  • Electron version 30
  • Using Electron builder (25.0.0-alpha.9)

At the time of installation, I want my app to get registered for handling the 'tel' protocol. My application should be listed in the supported applications

  • For windows
  1. I tried adding following key under electron builder config. under 'win' key and at high level too. protocols: [ { name: 'tel', schemes: ['tel'], }],

  2. I can run the post install script but did not find the parameter to which we can assign the post install script path in electron builder config.

  • For MAC
  1. Updated info.plist, added following information

    CFBundleURLTypes CFBundleURLName tel CFBundleURLSchemes tel

On windows, when I try Win+R -> // It does not list my application in the list.

On MAC too, its not working.

  • Electron version 30
  • Using Electron builder (25.0.0-alpha.9)

At the time of installation, I want my app to get registered for handling the 'tel' protocol. My application should be listed in the supported applications

  • For windows
  1. I tried adding following key under electron builder config. under 'win' key and at high level too. protocols: [ { name: 'tel', schemes: ['tel'], }],

  2. I can run the post install script but did not find the parameter to which we can assign the post install script path in electron builder config.

  • For MAC
  1. Updated info.plist, added following information

    CFBundleURLTypes CFBundleURLName tel CFBundleURLSchemes tel

On windows, when I try Win+R -> // It does not list my application in the list.

On MAC too, its not working.

Share Improve this question asked Jan 29 at 12:13 Shivangi DeshpandeShivangi Deshpande 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0
  1. For MAC , we need to add following key in electron builder configs / in package.json if you have defined build object in it. Add this key at high level, not under 'mac'.

    protocols: [ { name: 'app-name', schemes: ['tel'], }, ]

  2. For Windows , we need to make changes in windows registry. I didn't find any existing parameter available for builder config for this. I am using 'nsis' for windows where we can write our own custom script. I just wanted to make registry changes on install and revert on uninstall so I went with 'include' option. Find details here: https://www.electron.build/nsis.html#custom-nsis-script

To make changes in windows registry, we need admin privileges. To allow nsis to ak for permission , we need to add following line in builder config under nsis key

allowElevation:true

Now we need to write .nsh file which will be included. Under nsis key we will include our .nsh file

include:'/installer.nsh'

Under installer.nsh we will have following code

RequestExecutionLevel admin  # Request admin privileges
!define APP_NAME "app-name"
!define APP_PATH "$INSTDIR\${APP_NAME}.exe"
!macro customInstall
  WriteRegStr HKCU "Software\${APP_NAME}\\Capabilities" "ApplicationName" "${APP_NAME}"
  WriteRegStr HKCU "Software\${APP_NAME}\\Capabilities" "ApplicationDescription" "${APP_NAME}"
  WriteRegStr HKCU "Software\${APP_NAME}\\Capabilities\\URLAssociations" "tel" "${APP_NAME}.tel"
  WriteRegStr HKCU "Software\RegisteredApplications" "${APP_NAME}" "Software\${APP_NAME}\Capabilities"
  WriteRegStr HKCU "Software\\Classes\\${APP_NAME}.tel\\DefaultIcon" "" "${APP_PATH}"
  WriteRegStr HKCU "Software\\Classes\\${APP_NAME}.tel\\shell\\open\\command" "" "${APP_PATH} %1"
!macroend
!macro customUnInstall
  DeleteRegKey HKCU "Software\${APP_NAME}"
  DeleteRegKey HKCU "Software\\Classes\\${APP_NAME}.tel"
  DeleteRegValue HKCU "Software\RegisteredApplications" "${APP_NAME}"
!macroend

This will register your application for tel protocol on install and revert the registry changes on uninstall.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745299068a4621324.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信