Tech Blog

External Links from within the AEK

Often when building an AEK screen you’ll want to link outside of the AEK screen you’re working on. Whether that’s another AEK screen, or even outside of the app completely, it’s good practise to make sure the URL is encoded correctly to avoid complications across the wide range of devices and browsers your links can be accessed from.

For a typical link out of the app, it’s best to use the openURL campusM URL Scheme. Here’s a quick JavaScript example of this:

let href = "campusm://openURL?url=" + encodeURIComponent(url) + "&type=external";

This sets the URL scheme, encodes the URL to be linked to (to prevent issues with browsers automatically attempting to encode the contents of the URL), and also sets the parameter “type” to “external”, which opens the link in the device’s (default) external browser, instead of using the in-app webview. This is an optional parameter, and can be excluded completely, or added in some form of condition, for example:

// state set elsewhere based on user input
let openExternally = this.state.tickedOpenExternallyCheckbox;
let href = "campusm://openURL?url=" + encodeURIComponent(url);
if(openExternally) {
  href  = href + "&type=external";
}

For other campusM URL Schemes, please refer to this Knowledge Center article.

Leave a Reply