macosshellcustom-protocol

How to add a custom URL scheme programmatically on macOS?


I need to create a URL scheme that will allow me to open a file with its default software.

For this, I have an .app file that contains the function to open a file via a sent parameter:

myCustomProtocol://Users/xxx/indesign/A.indd

So I managed to make it work by doing everything manually via: https://hublog.hubmed.org/archives/001154

I would now like to automate this URL scheme creation via a script (for the moment, I use SwiftDefaultApps: https://github.com/Lord-Kamina/SwiftDefaultApps).

enter image description here

The .app file will be provided to the user but I must be able to install the custom protocol when installing an application.

Here I have to create a URL scheme programmatically that runs this .app file (like this example with Zoom).

enter image description here

I did my research before making this post but did not find any clear answers.

Thank you in advance !


Solution

  • Just launch the .app file manually and restart the Mac (?) to register the url scheme in macos.

    I can then call my custom protocol.

    Source: https://github.com/chrisliuqq/mac-custom-url-scheme-to-script