Attributes for the Android SDK

Set channel and contact attributes as key-value pairs for personalization.

For information about Attributes, including overview, use cases, and how to target Attributes, see About Attributes.

Channel Attributes

Channel attributes are attributes managed on the Channel by the SDK.

Channel attributes

Airship.channel.editAttributes {
    setAttribute("device_name", "Bobby's Phone")
    setAttribute("average_rating", 4.99)
    removeAttribute("vip_status")
}
Airship.getChannel().editAttributes()
    .setAttribute("device_name", "Bobby's Phone")
    .setAttribute("average_rating", 4.99)
    .removeAttribute("vip_status")
    .apply();

Contact Attributes

Contact attributes are attributes managed on the Contact by the SDK.

Contact attributes

Airship.contact.editAttributes {
    setAttribute("first_name", "Bobby")
    setAttribute("birthday", Date(524300400000))
}
Airship.getContact().editAttributes()
    .setAttribute("first_name", "Bobby")
    .setAttribute("birthday", Date(524300400000))
    .apply();

JSON Attributes

JSON Attributes are data objects containing one or more string, number, date, or boolean key-value pairs.

Android SDK 19.6+

You can set and remove JSON Attributes on a Channel or a Contact.

Modifying JSON attributes

Airship.contact.editAttributes {
    setAttribute(
        attribute = "attribute_name",
        instanceId = "instance_id",
        expiration = Date(),
        json = jsonMapOf(
            "key" to "value",
            "another_key" to "another_value"
        )
    )
}

Verifying Attributes

To verify that attributes are set correctly, look up the channel or contact in the Contact Management view. Search by Channel ID or Named User ID to view the attributes associated with a channel or contact.