iOS Attributes

Attributes can be used to customize the content of a message. The replacement is done using a subset of the mustache format:

{{ user.attribute | default }}

default is optional. For example, using {{ user.attribute }} will be replaced with an empty string if the attribute is not set.

For example, you can set a user's name in your app with the code below:

OpenBack.setValue("Bob" as NSCoding, forAttribute: "firstName")

Then in the dashboard, you can use this attribute in your message. The message below will say Hey Bob!, but will fallback to Hey player! if no name is found.

Hey {{ | player }}!

Full API documentation here

Setting an attribute value

An Attribute value can be any type that can be JSONified (string, number, array, pojo). You can set any number of attributes but during the application runtime, they can take extra memory space.

OpenBack.setValue("Bob" as NSCoding, forAttribute: "firstName")
OpenBack.setValue(42 as NSCoding, forAttribute: "answer")
OpenBack.setValue(235.4 as NSCoding, forAttribute: "wallet")

Clearing an attribute value

OpenBack.setValue(nil, forAttribute: "firstName")
// Clear all the attributes

Getting an attribute value

// Get the Object value of attribute "name"
// If value is null, attribute "name" is not set
var firstName = OpenBack.getAttribute("firstName")

Getting all attributes

Get all the attributes currently stored.

var attributes = OpenBack.getAllAttributes()

Pre-defined Attributes

The OpenBack SDK comes with pre-defined attributes that you can use to personalize the content of a notification. Simply store the appropriate user information within these attributes. The list of pre-defined attributes can be seen below:

AttributeExample Usage
AdvertisingId{{ user.advertisingId }}