Is there a way of detecting whether a url handler exists for a particular protocol?

@TomCatchesides re : is there a handler ?
On macOS you might prefer NSWorkspace URLForApplicationToOpenURL
This returns the URL for the default app if there is one
I’d bet MBS has a call for this as well

The LaunchServices call is deprecated

1 Like

This trick is how I get my help files to open in your web browser even if you have HTML files set to open with a text editor. Ask NSWorkspace which app opens https:// and send the file there instead of FolderItem.Open.

There’s no guarantee it WILL be any particular one
The order isnt guaranteed

All this will tell you is there IS something that says it can open a particular URL

And, unlike the launch services API there doesnt seem to be one that returns the URI’s for everything that says it CAN open a specific URI
But it strikes me there should be since that data is all recorded somewhere in the launch services databases

It looks like the MBS plugin has a way:

We also have:
shared method URLForApplicationToOpenURL(url as string) as string

Thanks, @npalardy ! (and everyone else who’s contributed to this)

1 Like

That likely uses the deprecated API I mentioned

I added the declares for this in the Ohanaware App Kit, I don’t recall is I used NSWorkspace or not. I’ll check later on in the day.

I needed to know which e-mail client the customer was using so I could offer to attach files or not to the e-mail. Apple’s Sharing Services completely suck in recent years, Apple used to handle this for you, but since “Privacy” they only care about Apple Mail.

That’s so Apple-like, these days… :roll_eyes:

1 Like

God forbid we provide anything super useful
Secure ? yeah we got that covered !
Deprecate everything !


The code I use in the public OAK demo app is as follows.

dummyURL                  = NSURLWithString( NSURLClass, "" )
Dim webBrowser as integer = NSWorkspaceURLForApplicationToOpenURL( NSWorkspaceSharedWorkspace, dummyURL )
if webBrowser <> 0 then
  list.append new textAndIconRow( "Web Browser", NSURLDisplayName( webBrowser ), NSWorkspaceIconForFile( NSWorkspaceSharedWorkspace, NSURLPath( webBrowser ) ) )
end if