As you learn new things about your mobile app's users, you may want to save data to their Iterable profiles. Your marketing team can then use this information to send them personalized messages.
Additionally, you may want to update their subscription preferences, so that they only receive content they want.
This guide describes how to save user profile data and update subscription preferences using Iterable's React Native SDK.
# In this article
# Saving user profile data
To save data to a user's Iterable profile, call the static updateUser method
on the Iterable class.
# Method declaration
static updateUser( dataFields: any, mergeNestedObjects: boolean )
| Parameter Name | Description |
|---|---|
dataFields | Data to store on the user's Iterable profile. |
mergeNestedObjects | Whether to merge top-level objects included in dataFields with analogous, existing objects on the user profile (if true) or overwrite them (if false). |
# Description
Saves the provided data to the user's Iterable profile. If mergeNestedObjects
is true, top-level objects in dataFields are merged with their counterparts
that already exist on the user's profile; otherwise, they're added.
IMPORTANT
mergeNestedObjects only works for data that is stored up to one
level deep within an object (for example, {mySettings:{mobile:true}}). Note
that mergeNestedObjects applies to objects,
not arrays.
# Example
Iterable.updateUser( { "firstName": "Joe", "favorites": { "color": "red", "flavor": "cinnamon" } }, false );
This call adds the firstName field and favorites object to the current
user's Iterable profile. Since mergeNestedObjects is false, this call will
overwrite the existing favorites object (if there is one), replacing it with
the value in the call (otherwise, it would have merged the two favorites
objects).
# Updating subscription preferences
To update a user's subscribed email lists, unsubscribed channel IDs, unsubscribed
message type IDs (for opt-out message types) and subscribed message type IDs (for
opt-in message types), call the static updateSubscriptions method on the
Iterable class.
# Method declaration
static updateSubscriptions( emailListIds: Array<number> | undefined, unsubscribedChannelIds: Array<number> | undefined, unsubscribedMessageTypeIds: Array<number> | undefined, subscribedMessageTypeIds: Array<number> | undefined, campaignId: number, templateId: number )
| Parameter Name | Description |
|---|---|
emailListIds or userListIds
| The lists to which the user should be subscribed. Parameters depend on project type. |
unsubscribedChannelIds | The message channels from which the user should be unsubscribed. |
unsubscribedMessageTypeIds | The message types from which the user should be unsubscribed (for opt-out message types). |
subscribedMessageTypeIds | The message types to which the user should be subscribed (for opt-in message types). |
campaignId | The campaign to associate with events generated by this request. Use -1 if unknown or not applicable. |
templateId | The template to associate with events generated by this request. Use -1 if unknown or not applicable. |
For emailListIds or userListIds, unsubscribedChannelIds,
unsubscribedMessageTypeIds, or subscribedMessageTypeIds, provide all values
relevant to the user —not deltas. For any of these arrays, use null to
indicate that Iterable should not change the current value on the user's
profile.
TIP
For more information about message channels and types, read Message Channels and Message Types Overview.
# Description
Updates the user's subscriptions.
# Example
Iterable.updateSubscriptions( null, [33015,33016,33018], null, null, 12345, 67890 );
This call unsubscribes the user from channels 33015, 33016 and 33018,
attributing the change to the campaign with ID 12345 and the template with ID
67890.