Static
loggerLogger for the Iterable SDK Log level is set with IterableLogLevel
Static
savedCurrent configuration of the Iterable SDK
Static
inIn-app message manager for the current user.
This property provides access to in-app message functionality including retrieving messages, displaying messages, removing messages, and more.
Static
disableStatic
getGet the stored attribution information -- possibly based on a recent deep link click.
The attribution information contains the campaign ID, template ID, and message ID of the message that prompted the user to recently click a link.
Static
getStatic
getStatic
getStatic
handleHandle a universal link.
handleAppLink
will hand the passed in URL to IterableConfig.urlHandler
, where it is determined whether or not
the app can handle the clicked URL.
This can be used to handle deep links, universal links, and other URLs that the app should handle.
The tracking URL generated by Iterable for the link you included in your message content.
When you call Iterable.handleAppLink,
you'll pass a URL—the tracking URL
generated by Iterable for the link you included in your message content.
handleAppLink
will fetch the original URL (the one you added to your
message) from Iterable
and hand it to IterableConfig.urlHandler
, where you
can analyze it and decide what to do (for example, you might navigate the
user to a particular screen in your app that has content related to the
link).
graph TD;
A[Linking event listener] --> B[Iterable.handleAppLink] --> C[IterableConfig.urlHandler];
Basic usage is as follows:
Iterable.handleAppLink('https://www.example.com').then((handled) => {
console.log('Link handled: ' + handled);
});
For deep linking, your code would look something like this:
import { Linking } from 'react-native';
const MyApp = () => {
// To handle deep links clicked when the app is not running,
// implement `Linking.getInitialURL`:
Linking.getInitialURL().then((url) => {
if (url) {
Iterable.handleAppLink(url);
}
});
// To handle deep links clicked when the app is already open
// (even if it's in the background), implement
// `Linking.addEventListener('url', callback)`
Linking.addEventListener('url', (event) => {
if (event.url) {
Iterable.handleAppLink(event.url);
}
});
// This, in turn, will call your `urlHandler` function on the
// `IterableConfig` object you used to initialize the SDK.
const config = new IterableConfig();
config.urlHandler = (url) => {
const isCoffeeUrl = url.search(/coffee/i) !== -1;
if (isCoffeeUrl) {
// Navigate to the coffee screen
}
return isCoffeeUrl;
};
return ( /* Your app code here * / );
}
Static
inRemove the specified message from the current user's message queue.
This creates an in-app delete event for the specified message on the current user's profile
unless otherwise specified (specifying a source of IterableInAppDeleteSource.unknown prevents
an inAppDelete
event from being created).
The in-app message (an IterableInAppMessage object)
The location of the in-app message (an IterableInAppLocation enum)
How the in-app message was deleted (an IterableInAppDeleteSource enum)
const message = new IterableInAppMessage(
1234,
4567,
IterableInAppTrigger.auto,
new Date(),
new Date(),
false,
undefined,
undefined,
false,
0,
);
Iterable.inAppConsume(message, IterableInAppLocation.inApp, IterableInAppDeleteSource.delete);
After a user has read an in-app message, you can consume it so that it's no longer in their queue of messages. When you use the SDK's default rendering for in-app messages, it handles this automatically. However, you can also use this method to do it manually (for example, after rendering an in-app message in a custom way).
Static
initializeInitializes the Iterable React Native SDK in your app's Javascript or Typescript code.
Pass in a mobile API key distributed with the mobile app. Warning: never user server-side API keys with the React Native SDK, mobile API keys have minimal access for security purposes.
Pass in an IterableConfig
object with the various customization properties setup.
WARNING: Never use server-side API keys with Iterable's mobile SDKs. Since API keys are, by necessity, distributed with the mobile apps that contain them, bad actors can potentially access them. For this reason, Iterable provides mobile API keys, which have minimal access.
The mobile API key for your application
Configuration object for the SDK
Initializing the app could look like this:
// Create a new IterableConfig object
const config = new IterableConfig();
// Set various properties on the config object
config.logLevel = IterableLogLevel.debug;
// Initialize the SDK with the API key and config object
Iterable.initialize(API_KEY, config);
Static
setManually set the current stored attribution information so that it can later be used when tracking events.
The attribution information contains the campaign ID, template ID, and message ID of the message that prompted the user to recently click a link.
Optional
attributionInfo: IterableAttributionInfoObject storing current attribution info
Static
setAssociate the current user with the passed in email parameter.
Note: specify a user by calling Iterable.setEmail
or
Iterable.setUserId
, but NOT both
Optional
email: null | stringEmail address to associate with the current user
Optional
authToken: null | stringValid, pre-fetched JWT the SDK can use to authenticate API requests, optional - If null/undefined, no JWT related action will be taken
Iterable's React Native SDK persists the user across app sessions and
restarts, until you manually change the user using Iterable.setEmail
or
Iterable.setUserId
.
If your Iterable project does not have a user with the passed in email,
setEmail
creates one and adds the email address to the user's Iterable
profile.
If IterableConfig.autoPushRegistration
is set to true, calling
setEmail
automatically registers the device for push notifications and
sends the deviceId and token to Iterable.
An optional valid, pre-fetched JWT can be passed in to avoid race conditions. The SDK uses this JWT to authenticate API requests for this user.
To tell the SDK to sign out the current user, pass null into
Iterable.setEmail
. If IterableConfig.autoPushRegistration is set to
true, calling Iterable.setEmail
(null) prevents Iterable from sending
further push notifications to that user, for that app, on that device. On
the user's Iterable profile, endpointEnabled
is set to false for the
device.
Static
setAssociate the current user with the passed in userId
parameter.
Note: specify a user by calling Iterable.setEmail
or
Iterable.setUserId
, but NOT both.
Optional
userId: null | stringUser ID to associate with the current user
Optional
authToken: null | stringValid, pre-fetched JWT the SDK can use to authenticate API requests, optional - If null/undefined, no JWT related action will be taken
Iterable's React Native SDK persists the user across app sessions and
restarts, until you manually change the user using Iterable.setEmail
or
Iterable.setUserId
.
If your Iterable project does not have a user with the passed in UserId
,
setUserId
creates one and adds a placeholder email address to the user's
Iterable profile.
If IterableConfig.autoPushRegistration
is set to true
, calling
setUserId
automatically registers the device for push notifications and
sends the deviceId
and token to Iterable.
An optional valid, pre-fetched JWT can be passed in to avoid race conditions. The SDK uses this JWT to authenticate API requests for this user.
To tell the SDK to sign out the current user, pass null into
Iterable.setUserId
. If IterableConfig.autoPushRegistration
is set to
true, calling Iterable.setUserId(null)
prevents Iterable from sending
further push notifications to that user, for that app, on that device. On
the user's Iterable profile, endpointEnabled is set to false for the
device.
Static
trackCreate a custom event to the current user's Iterable profile.
Pass in the name of the event stored in eventName key and the data associated with the event. The eventType is set to "customEvent".
The event name of the custom event
Optional
dataFields: unknownDescriptive data to store on the custom event
Static
trackCreate an inAppClick
event for the specified message on the current user's profile
for manual tracking purposes. Iterable's SDK automatically tracks in-app message clicks when you use the
SDK's default rendering. Click events refer to click events within the in-app message to distinguish
from inAppOpen
events.
The in-app message.
The location of the in-app message.
The URL clicked by the user.
Static
trackCreate an inAppClose
event for the specified message on the current
user's profile for manual tracking purposes. Iterable's SDK automatically
tracks in-app message close events when you use the SDK's default
rendering.
The in-app message.
The location of the in-app message. Useful for determining if the messages is in a mobile inbox.
The way the in-app was closed.
Optional
clickedUrl: stringThe URL clicked by the user.
Static
trackCreate an inAppOpen
event for the specified message on the current user's profile
for manual tracking purposes. Iterable's SDK automatically tracks in-app message opens when you use the
SDK's default rendering.
The in-app message (an IterableInAppMessage object)
The location of the in-app message (an IterableInAppLocation enum)
Static
trackCreate a purchase event on the current user's Iterable profile.
Represent each item in the purchase event with an IterableCommerceItem object.
The total cost of the purchase
The items included in the purchase
Optional
dataFields: unknownDescriptive data to store on the purchase event
Static
trackCreate a pushOpen
event on the current user's Iterable profile, populating
it with data provided to the method call.
NOTE: Iterable's SDK automatically tracks push notification opens. However, it's also possible to manually track these events by calling this method.
The ID of the campaign to associate with the push open
The ID of the template to associate with the push open
The ID of the message to associate with the push open
Whether or not the app was already running when the push notification arrived
Optional
dataFields: unknownInformation to store with the push open event
const CAMPAIGN_ID = 12345;
const TEMPLATE_ID = 67890;
const MESSAGE_ID = '0fc6657517c64014868ea2d15f23082b';
const APP_ALREADY_RUNNING = false;
const DATA_FIELDS = {
"discount": 0.99,
"product": "cappuccino",
};
Iterable.trackPushOpen(CAMPAIGN_ID, TEMPLATE_ID, MESSAGE_ID, APP_ALREADY_RUNNING, DATA_FIELDS);
Static
updateUpdate the items saved in the shopping cart (or equivalent).
Represent each item in the updateCart event with an IterableCommerceItem object.
The items added to the shopping cart
Static
updateChange the value of the email field on the current user's Iterable profile.
If Iterable.setUserId
was used to identify the current user, Iterable.updateEmail
can be called to
give the current user a real (non-placeholder) email address.
An optional valid, pre-fetched JWT can be passed in to avoid race conditions. The SDK uses this JWT to authenticate API requests for this user.
The new email to set
Optional
authToken: stringThe new auth token (JWT) to set with the new email, optional - If null/undefined, no JWT-related action will be taken
Static
updateUpdate the current 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) on the current user's profile.
Pass in null for any of emailListIds
, unsubscribedChannelIds
, unsubscribedMessageTypeIds
, or subscribedMessageTypeIds
to indicate that Iterable should not change the current value on the current user's profile.
The list of email lists (by ID) to which the user should be subscribed
The list of message channels (by ID) to which the user should be unsubscribed
The list of message types (by ID) to which the user should be unsubscribed (for opt-out message types)
The list of message types (by ID) to which the user should be subscribed (for opt-in message types)
The campaign ID to associate with events generated by this request, use -1
if unknown or not applicable
The template ID to associate with events generated by this request, use -1
if unknown or not applicable
const emailListIds = [1234, 5678];
const unsubscribedChannelIds = [1234, 5678];
const unsubscribedMessageTypeIds = [1234, 5678];
const subscribedMessageTypeIds = [1234, 5678];
const campaignId = 1234;
const templateId = 5678;
Iterable.updateSubscriptions(
emailListIds,
unsubscribedChannelIds,
unsubscribedMessageTypeIds,
subscribedMessageTypeIds,
campaignId,
templateId,
);
Static
updateSave data to the current user's Iterable profile.
If mergeNestedObjects
is set to true
, top-level objects in the passed in dataFields parameter
are merged with their counterparts that already exist on the user's profile.
Otherwise, they are added.
If mergeNestedObjects
is set to false
, the top-level objects in the passed in dataFields parameter
overwrite their counterparts that already exist on the user's profile.
Otherwise, they are added.
Data fields to store in user profile
Whether to merge top-level objects included in
dataFields with analogous, existing objects on the user profile (if true
)
or overwrite them (if 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).
Iterable.updateUser(
{
"firstName": "Joe",
"favorites": {
"color": "red",
"flavor": "cinnamon"
}
},
false
);
Static
wake
The main class for the Iterable React Native SDK.
The majority of the high-level functionality can be accomplished through the static methods of this class. EG: initializing the SDK, logging in a user, tracking purchases, etc.
Example