Custom HTML Templates for Rich Pages


Airship provides several predefined templates for sending rich pages A landing page or Message Center message in your app that can include HTML, video, etc. to the device. Custom templates are also supported by uploading an HTML page.

JavaScript Interface

Both iOS and Android/Amazon load an Airship JavaScript interface into every landing page and Message Center message. This interface allows the HTML pages to access information about the system and trigger actions. The interface is available on both platforms, namespaced by a global UAirship object.



The App Key in the UA system, e.g., Wx7SIqAdJDmFj6ar97AFcQ. Available in UA Android 8.3.0 SDK and iOS 8.2.0 SDK.


The user's ID in the UA system, e.g., 4e84b80563051f67ec001a87.


The channel ID in the UA system, e.g., 45741d38-2dab-4c7b-8981-41423e078959. Available in UA Android 7.2.0 SDK and iOS 7.2.2 SDK.


The named user ID associated to the channel, e.g. SomeNamedUserId. Available in UA Android 7.2.0 SDK and iOS 7.2.2 SDK.


The device model on which the user is viewing the Message Center message, e.g., iPod Touch, XT1053.


Closes the current landing page or Message Center message.

  • Android: Simulates a Back button.
  • iOS: If the webview's delegate implements the protocol UARichContentWindow , it will call closeWindow.

UAirship.runAction(actionName, argument, callback)

Triggers an action asynchronously. Any action that is registered in the device's action registry is able to be triggered from JavaScript. For more information on actions, including a list of available actions and how to write custom actions, see Android Actions and iOS Actions.

  • actionName — The name of the action to trigger.
  • argument — The value of the action's argument in the form of any valid JSON.
  • callback — Callback when the action finishes. Invoked with an instance of an Error if an error occurred and any result data from the action.


// Triggers the add tags action with tag "MY_TAG"
UAirship.runAction("add_tags_action", "MY_TAG", function(error, result) {
  console.log("add_tags_action finished")
  if (!error) {
    console.log("Added MY_TAG")
  } else {
    console.log("Failed to add MY_TAG")

console.log("add_tags_action called")

The callback will be called after the action has finished executing. The earliest the callback will ever be triggered is during the next turn of the event loop, i.e., the example above will always log add_tags_action called before add_tags_action finished.


The message ID being displayed or null for landing pages.


The message's sent date in GMT with format yyyy-MM-dd HH:mm:ss or null for landing pages.


The message's sent date in milliseconds (Unix epoch time) or -1 for landing pages.


The message's title or null for landing pages.

Events Reference


Fired once the UAirship interface is fully loaded. This event will be fired after the content of the page is loaded.


// Check if the interface is fully loaded
if(typeof UAirship === 'object' && UAirship.runAction) {
} else {
  document.addEventListener('ualibraryready', onload, false)

URL Intercepting

Any URLs with the scheme uairship will be intercepted by the Airship SDK.



Runs action with implicit string arguments. Actions and the arguments are defined by the URI parameters.


<a href="uairship://run-basic-actions?add_tags_action=hi&">Add tags!</a>

Will add the tag hi when the user clicks the link.


The same as run-basic-actions, but the action's arguments are JSON encoded.


<!-- ["foo", "bar"] url encoded is %5B%22foo%22%2C%22bar%22%5D -->
<a href="uairship://run-actions?add_tags_action=%5B%22foo%22%2C%22bar%22%5D">Add tags!</a>

Will add the tags foo and bar to the device when the user clicks the link.

Custom Template Sample

Send a Message Center message or landing page with the following HTML.

      function onUAReady() {
        var output = document.getElementById('output')

        // Write out all of the getters
        output.textContent += 'User Id:' + UAirship.getUserId() + '\n'
        output.textContent += 'Channel Id:' + UAirship.getChannelId() + '\n'
        output.textContent += 'Named User Id:' + UAirship.getNamedUser() + '\n'
        output.textContent += 'Device Model: ' + UAirship.getDeviceModel() + '\n'
        output.textContent += 'Message Id: ' + UAirship.getMessageId() + '\n'
        output.textContent += 'Message Title: ' + UAirship.getMessageTitle() + '\n'
        output.textContent += 'Message Sent Date: ' + UAirship.getMessageSentDate() + '\n'
        output.textContent += 'Message Sent Date MS: ' + UAirship.getMessageSentDateMS()

        var closeButton = document.getElementById('close')
        closeButton.disabled = false
        closeButton.addEventListener('click', function()  {

        var addTagsButton = document.getElementById('addTags')
        addTagsButton.disabled = false
        addTagsButton.addEventListener('click', function()  {
            UAirship.runAction("add_tags_action", "hi", function(error, result) {
              if (error) {
                console.log("Failed to add tags!")
              } else {
                console.log("Tags added!")

        var openExternalURLButton = document.getElementById('openURL')
        openExternalURLButton.disabled = false
        openExternalURLButton.addEventListener('click', function()  {
            UAirship.runAction("open_external_url_action", "", function() {return true})


      document.addEventListener('ualibraryready', onUAReady, false)
    <button id="close" disabled>close</button><br><br>
    <button id="addTags" disabled>add tags</button><br><br>
    <button id="openURL" disabled>open external URL</button><br><br>
    <button onclick="location.href=''">open URL in webview</button>
    <pre id="output"></pre>