Using custom URL schemes
Specifying a custom URLs allow an application to be woken up when a specific URL is selected on a device. For example, the custom URL could be a home URL of the application web page.
This lesson uses 2 stacks,
1. The "launchee" stack, which is launched by a custom URL
2. The "launcher" stack, which calls the URL causing the first stack to launch.
The "launchee" stack can also be launched by entering the URL in a web browser.
The "launcher" stack consists of 3 buttons which launch various URLs. The custom URL of the "launchee" stack is "webme" and any URL beginning with that string will launch the app. The rest of the URL can contain arguments or extra information that can be used by the "launchee" stack.
The script of the top button is
on mouseUp launch url "webme://" end mouseUp
The other also use the launch url command.
This is the stack that is launched, it has a field to display the the URL that caused it to be launched and a button that uses the mobileGetLaunchURL function to display the URL.
The script of the button is
on mouseUp local tURL ## This function returns the URL that was used to launch the application. put mobileGetLaunchUrl() into tURL answer tURL with "Okay" end mouseUp
The "launchee" stack also handles the urlWakeUp message. This message is sent to an app when it is launched via a custom URL, it has 1 parameter, wakeUpString, which is the URL that launched the app. The "launchee" stack handles this message in the card script.
on urlWakeUp pURL ## This message is received by the app when a custom url is used to launch the app put pURL into field "url" end urlWakeUp
An app's custom url is specified the the iOS or Android pane of the Standalone Application Settings. In this example the custom URL we want to use is "webme".
Deploy both stacks to your simulator or device, open the "launcher" stack and click any of the buttons. The "launchee" stack will open and the URL you selected will be displayed in the field. If you click the "Get Launch URL" button and answer dialog will be shown displaying the URL.