I used xdg to set things up, so my custom URI would open in my custom desktop application. Things seem to work in the console. I tested it using both xdg-open
and gio open
:
$ xdg-open foobar:id=333
$ gio open foobar:id=444
Both run my script as intended.
When I go to my browser and click a hyperlink with the same URI, first a small dialogue appears to ask if I will allow the website to open xdg-open, and I accept.

Then xdg-desktop-portal appears and says that no apps are available.

I assume clicking Find More in Software wont help me, but would instead take me to the Ubuntu Software Application or similar. But if I do click it, I get:

The behavior is the same for both Firefox and Chromium.
However, magnet links work as expected, after installing Transmission.
Details from gio:
$ gio mime x-scheme-handler/foobar
Default application for “x-scheme-handler/foobar”: foobar.desktop
No registered applications
No recommended applications
Content of foobar.desktop:
[Desktop Entry]
Version=1.0
Name=Foobar Test Handler
GenericName=Foobar
Comment=Just for testing
Icon=/home/jdoe/foobar/icon.png
Path=/home/jdoe/foobar/
Exec=python /home/jdoe/foobar/handler.py %u
Terminal=false
Type=Application
Categories=Utility
MimeType=x-scheme-handler/foobar;
Im running Ubuntu 22.04.1 LTS.