Custom url with notarized package installer

I have a macOS application which I distribute in an installer .pkg. Both app and installer are notarized. The application is set to use a custom URL.

Now, with the upgrade to Catalina, when the application is installed through the installer, it cannot open custom URL, an alert is shown with 'There is no application set to open the URL ://'.

The strange fact is, if I run the application outside the installer, so simply drag and drop to the application folder, it works without any issue and open the custom URL.

Any idea of what is going on?

Replies

I suspect that notarisation is a red herring here, and that the real issue relates to the installer. If you run

lsregister
on the newly installed app, does the custom URL scheme start working?
$ lsregister -f /Applications/Your.app

Note You can find

lsregister
at
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister
.

Also, make sure you test this on a fresh machine. I generally do this sort of thing in a fresh VM, restoring to a snapshot between each test so that I get consistent results.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

That's correct! running the command on the fresh machine makes the app working, what does it means?

Furthermore I cannot run this custom command from the installer because it is not always present on the machine, or you suggest I should pack also the lsregister service file in the package installer?

Lemme clarify your setup here:

  1. You have an app that declares support for a custom URL scheme.

  2. To start your test, you restore a fresh snapshot that’s neven seen your app.

  3. You install your app via its installer package.

  4. Something opens a URL for that scheme, which then fails.

Is that correct?

My question is, in step 4, what’s opening the URL?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

The steps are correct.

In step 4 I have a redirect from a webview (an authentication server), which allows the user to login to the application, so the temporary code is sent back via the custom URL scheme.

In particular what happens is:

- user click on Login button

- a webview is open with the authentication provider

- the user fill the form

- once the form is submitted, a redirect happen on the page which call the custom URL scheme, this redirect fails because there is no app registered


P.S.: the application is set as a service, it 'lives' in the top bar of the screen


Antonio

In step 4 I have a redirect from a webview

OK, let me fill in some gaps here:

  1. You have an app that declares support for a custom URL scheme.

  2. To start your test, you restore a fresh snapshot that’s neven seen your app.

  3. You install your app via its installer package.

  4. You open a web page in Safari, which attempts to a open a URL with that custom URL scheme.

  5. Something displays an alert along the lines of “There is no application set to open the URL”.

In step 5, is the alert coming from Safari?

Here’s another sequence:

  1. You have an app that declares support for a custom URL scheme.

  2. To start your test, you restore a fresh snapshot that’s neven seen your app.

  3. You install your app via its installer package.

  4. You then launch your app for the first time.

  5. You open a web page in Safari, which attempts to a open a URL with that custom URL scheme.

What happens in this case?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

It is slightly different:

I open a new window, inside it I put a webview element.

At a certain point, this window brows a url which is registered as URL scheme of the application, at this point an alert popups stating that there is no application registered to open that url.

The special url is always open from inside my application.


I'm able to replicate it everytime I remove the app from the Applications folder and reinstall it via the package installer, furthermore if I 'install' manually (just moving the .app into the Applications folder) the url scheme is recognized as usual.

I open a new window, inside it I put a webview element.

So, both the source and the destination of this open-URL operation are your app? That is, the source is in a web view running within one of your app’s window and the destination is the app itself.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

This is not clear to me. You say that it is happening because the webview is trying to render the custom URL scheme?

Why this is not happening if the application is used without the installer?


I made a test calling the custom url scheme from safari and it says 'Safari can't open specified address' because it does not recognize the custom protocol. (In a mac with the working custom url scheme Safari is able to open the address)

I made a test calling the custom url scheme from Safari

OK, but do you actually care about that case? Based on your earlier post, I was assuming that the case you care about is opening the URL from a web view that your app is presenting. If so, you don’t need to go through the system’s URL opening mechanism. Rather, you can intercept the web view’s attempt to open the URL (using the web view’s navigation delegate) and handle the URL internally.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

ps DTS is closed 25…29 Nov in observance of the US Thanksgiving holiday.

I don't care for this case, since I can handle the url from the webview itself, but I have another case where the application is launched form another tool, another application I develop, and this is important to be launched

I have another case where the application is launched form another tool, another application I develop, and this is important to be launched

OK. Can you clarify the exact sequence of steps that’s failing? Ideally I’d like to see something like the scenarios I described in my 22 Nov post.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

ps DTS is closed 25…29 Nov in observance of the US Thanksgiving holiday.

I have an app which basically download a file, and when it finish it sends a callback to the first app


let url = URL(string: "mainapp://downloaded-finished?now=true")
NSWorkspace.shared.open(url!)
NSApp.terminate(nil)


At this point the alert popups stating that there is no app which is able to open that url scheme

I’m sorry but I need a more detailed explanation of what you’re doing to reproduce the problem. Again, I’m going to reference my 22 Nov, which shows the sort of step-by-step details I’m looking for.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

ps DTS is closed 25…29 Nov in observance of the US Thanksgiving holiday.