Tips and Tricks for the Airship + Movable Ink Integration

  1. Send the personalization information along with the API call that triggers the message
  2. Get the personalization information at load time, from the device or an API
  • Lock-Screen notifications (Rich Media displayed on Lock Screen has some limitations.)
  • Rich Message Center messages
  • Rich Message Center messages
  • Landing Pages
  • In-App Automations
{     “occurred”: “2020–07–20T06:00:00”,     “user”: {         “named_user_id”: “jg”     },     “body”: {         “name”: “golly”,         “interaction_type”: “crm”,         “value”: 1000,         “properties”: {             “first_name”: “John”,             “named_user”: “jg”,             “email_address”: “john@airship.com”          },          “session_id”: “cd1d893b-cafa-4636–9dac-d83138bef8bf”      }}

Personalization from a Broadcast Message

  1. Execute some custom code when the UAirship interface and page content are fully loaded
if(typeof UAirship === ‘object’ && UAirship.runAction) {onload()} else {document.addEventListener(‘ualibraryready’, onUAReady, false)}
  1. Grab the Named User and assign it to a variable
var named = UAirship.getNamedUser()
  1. Create an <img> element and insert it into the DOM
if(named !== null && named !== “”) {var replaceElement = document.getElementById(“banner_image”);var newImageElement = document.createElement(“img”);newImageElement.src = movable_ink_image + “?mi_u=” + encodeURI(named);replaceElement.firstChild.replaceWith(newImageElement);
var xhr = new XMLHttpRequest();xhr.open(‘GET’, url, true);xhr.setRequestHeader(“Accept”, “application/json”);xhr.send();xhr.onload = function() {    if (xhr.status != 200) {        console.log(`Error ${xhr.status}: ${xhr.statusText}`);    } else {        var json_response = JSON.parse(xhr.responseText);        var deep_link = json_response[‘location’];        var action = “^d”;        if (deep_link.startsWith(“http”)) {           action = “^u”;        }        UAirship.runAction(           action,           deep_link,           function() {               return true           }         )     }  }
function capture() {    // This creates a Custom Event object and sets it in the SDK    console.log(‘running custom event’)    var custom_event_object = {};        custom_event_object.event_name = “open_movable”;    custom_event_object.event_value = 1;    custom_event_object.properties = {};    custom_event_object.properties.customer_id = “” + UAirship.getNamedUser();    UAirship.runAction(“add_custom_event_action”, custom_event_object, true);    return;}

--

--

--

Urban Airship is now Airship! Leading brands trust us to help them achieve digital growth. We make mobile moments magic. www.airship.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What is TCP?

DynamoDB: The “Big Easy” of NoSQL

Serverless — AWS Lambda Layers and Python Dependencies

Vite Bi-weekly Report

6 Things We Learned From Our Hacking Days in Barcelona

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Airship

Airship

Urban Airship is now Airship! Leading brands trust us to help them achieve digital growth. We make mobile moments magic. www.airship.com

More from Medium

Week 4 — The Final Stretch

Load Up On Passion

Constant Output Week 9

Creating a Place of ‘Overwhelming Biodiversity’ from Scratch.