Set or Clear Attributes

Use the Salesforce Engagement SDK to set or clear attribute key-value pairs.

This code example shows how to set or clear attributes in the SDK for Android.

This code example shows how to set or clear attributes in the SDK for iOS version 10 and later.

This code example shows how to set or clear attributes in the SDK for Android version 8.

For earlier versions of the SDK for iOS, use this code.

Keep these requirements in mind when you set or clear attributes.

  • The attribute key can’t be a reserved word, empty, or null.
  • The attribute value can’t be null.
  • The SDK trims whitespace from the beginning and end of the key and the value.
  • Specify dates in ISO 8601 format, such as 2024-05-07T13:28:31+00:00.
  • If you set an attribute to a datetime stamp after the SDK successfully initializes, the registration record is updated every time the SDK initializes.
  • Don’t create an attribute with a datetime value that changes regularly. For example, don’t set an attribute that tracks LastUserInteraction. Frequently changing attribute values has a negative impact on performance.

Some words are reserved and can’t be used as attribute names. The SDK ignores attempts to set or clear attributes that contain any of these words.

  • addressId
  • alias
  • apId
  • backgroundRefreshEnabled
  • badge
  • channel
  • contactId
  • contactKey
  • createdBy
  • createdDate
  • customObjectKey
  • device
  • deviceId
  • deviceType
  • gcmSenderId
  • hardwareId
  • hwid
  • isHonorDst
  • lastAppOpen
  • lastMessageOpen
  • lastSend
  • locationEnabled
  • messageOpenCount
  • modifiedBy
  • modifiedDate
  • optInDate
  • optInMethodId
  • optInStatusId
  • optOutDate
  • optOutMethodId
  • optOutStatusId
  • platform
  • platformVersion
  • providerToken
  • proximityEnabled
  • pushAddressExtensionId
  • pushApplicationId
  • quietPushEnabled
  • sdkVersion
  • sendCount
  • signedString
  • source
  • sourceObjectId
  • status
  • systemToken
  • timezone
  • utcOffset