Creating a custom protocol? i.e. myapp://launch/view/index

Hi,
About 10 years ago, I created a custom protocol using Visual Basic 6.

It would allow somebody to send a link such as myapp://launch/view/index

I would also embed them in a webpage, so people could launch my app. Current apps that do this are Spotify and iTunes.

Any recommendations on where to start or if this is even possible?

Thanks,
Luis

Which system ? Mac or Windows ?

For Mac, I found the description of how to implement anew protocol by modifying the Safari bundle at
https://yourmacguy.wordpress.com/2013/07/17/make-your-own-url-handler/

Windows Control Panel lets you specify which program opens which protocol. Control Panel / Internet Preferences, Programs Tab, Set associations. In there, you will find URL:Mailto and the associated program. You can modify a key to associate it with your program.

These informations are stored in the registry and can be found with Regedit, then added by program through Xojo RegistryItem.

Then it is up to you to define the name of your protocol, and devise the program to go with it. Your VB experience can be applied.

When I did this in VB6, I setup the registry keys in app.

I was hoping there was a cross platform implementation built-in to Xojo…

I don’t expect my users to run a script on OSX. So, for mac, it sounds like I just need to port that code to Xojo? I’m really new to Xojo, but it’s coming easy. I imagine this would be done through some sort of File i/o of writing to directories, but then you could run into permissions I imagine?

[quote=84902:@Luis Gonzalez]When I did this in VB6, I setup the registry keys in app.

I was hoping there was a cross platform implementation built-in to Xojo…

I don’t expect my users to run a script on OSX. So, for mac, it sounds like I just need to port that code to Xojo? I’m really new to Xojo, but it’s coming easy. I imagine this would be done through some sort of File i/o of writing to directories, but then you could run into permissions I imagine?[/quote]

Apply what you know in VB on Windows, and you should feel home with Xojo.

Apple uses some custom protocols, such as macappstores:// but as you can see from the link I posted, it is a lot more involved than on PC. Modifying the info.plist in a bundle from a program or script is strictly forbidden, so there is no way to do it easily.

But from what I can see, you could add the proper URL handler to your app. Here is the example from the App Store info.plis :

<key>CFBundleURLSchemes</key> <array> <string>macappstores</string> </array>

So you could try to build an app, modify the info.plist by following the instructions from yourmacguy, and see if it opens when you send an url with your custom protocol.

As you can see, there could not be an easy cross platform solution, as each system takes a different approach. But now you have pointers to do what you seek.

See https://developer.apple.com/library/mac/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html

CFBundleURLTypes

In windows you will want to create a registry… lets say we have a custom uri as “alert://”

You will want to use the registry class to create the following structure:
HKEY_CLASSES_ROOT
alert
(Default) = “URL:MyApp Protocol”
URL Protocol = “”
DefaultIcon
(Default) = “MyApp.exe,1”
shell
open
command
(Default) = “C:\Destination\To\MyApp.exe” “%1”

…OR…
create a MyApp.Reg file with the following contents

[HKEY_CLASSES_ROOT\\MyApp]
@="MyApp URI"
"Content Type"="application/x-myapp"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\\MyApp\\DefaultIcon]
@="C:\\\\Destination\\\\To\\\\MyApp.exe,0"

[HKEY_CLASSES_ROOT\\MyApp\\shell]
@="open"

[HKEY_CLASSES_ROOT\\MyApp\\shell\\open]

[HKEY_CLASSES_ROOT\\MyApp\\shell\\open\\command]
@="\"C:\\\\Destination\\\\To\\\\MyApp.exe\" \"%1\""

and run the following command to silently load the new registry file into the Windows Hive/Registry system…

regedit.exe /s path of .reg file

I guess this is as good as any a place to post about Facebook’s proposal to implement “deep linking” within applications.

Based precisely in iOS’s implementation of URL inter-application communication Facebook is proposing to use this to be able to map between web apps and applications by using URLs with additional datas into their AppLinks standard:

http://applinks.org/

This is interesting to consider since it covers some of the needs currently between (iOS) applications but as a side effect they’re also perfectly adoptable for desktop applications.

In a way, this makes adopting a scheme like Android’s Intents for all applications much easier (as long as it’s widely adopted).