Packages and Configuration Options
UpdatedHow it works
With our Expo plugin, you’ll add configuration options in two places:
- In your
app.json
orapp.config.js
files, you’ll add configuration options that affect the native files we generate when you run the prebuild. - In your React Native app, you’ll add configuration options that affect the SDK at runtime.
Configuring the Expo Plugin
To use the Expo plugin, you’ll need to add a customerio-expo-plugin
entry to your App.json
{
"plugins": [
[
"customerio-expo-plugin",
{
"android": {
"googleServicesFile": "./files/google-services.json"
},
"ios": {
"pushNotification": {
"useRichPush": true,
"env": {
"cdpApiKey": "<apiKey>",
"region": "<region>"
}
}
}
}
]
]
}
Option | Type | Default | Description |
android | object | Required if you want to setup Android even if it is empty. Eg ("android": {} ). | |
android.googleServicesFile | string | Set the path to your google-services.json file. | |
android.setHighPriorityPushHandler | boolean | This is optional, if you choose to use a 3rd party plugin to handle notification permissions, but want our SDK to handle the notifications. | |
ios | object | Required: The parent object for iOS settings, including your initialization keys. | |
ios.pushNotification | object | Required Enables push notifications for iOS. | |
ios.pushNotification.useRichPush | boolean | false | Enables rich push features for iOS (images and links). |
ios.pushNotification.env | object | Required Contains your API key (env.cdpApiKey ) and region (env.region with one of eu or us ) information. | |
ios.useFrameworks | string | (Optional) Allows the plugin to work with static libraries. Options are static and dynamic | |
ios.disableNotificationRegistration | boolean | true | (Optional) Removes the registerPushNotification handler and allows you to control notification permission requests. We recommend that you set this to true (default) if you have customerio-reactnative version >= 2.2.0 installed. |
ios.showPushAppInForeground | boolean | true | Set to true if you want push notifications sent by Customer.io to be shown when your app is in the foreground. |
ios.handleDeeplinkInKilledState | boolean | false | Set to true if you want the Customer.io SDK to handle deep links when your app is in a killed/closed state. |
SDK packages
The SDK consists of a few packages. You must use the CioConfig
and CustomerIO
packages to configure and initialize the SDK in your React Native app.
Package Product | Required? | Description |
---|---|---|
CustomerIO | ✅ | The main SDK package. Used to initialize the SDK and call the SDK’s methods. |
CioConfig | ✅ | Configure the SDK including in-app messaging support. |
CioRegion | Used inside the CioConfig.region option to declare your region—EU or US. | |
CioLogLevel | Used inside the CioConfig.logLevel option to set the level of logs you can view from the SDK. |
React configuration options
You can determine global behaviors for the SDK in using CioConfig
package. You must provide configuration options before you initialize the SDK; you cannot declare configuration changes after you initialize the SDK.
Import CioConfig
and then set configuration options to configure things like your logging level and whether or not you want to automatically track device attributes, etc. Note that the logLevel
option requires the CioLogLevel
package and the region
option requires the CioRegion
package.
import {
CioLogLevel, CioRegion, CustomerIO, CioConfig
} from 'customerio-reactnative';
const App = () => {
useEffect(() => {
const config: CioConfig = {
cdpApiKey: 'CDP API Key', // Mandatory
migrationSiteId: 'siteId', // Required if migrating from an earlier version
region: CioRegion.US,
logLevel: CioLogLevel.Debug,
trackApplicationLifecycleEvents: true,
inApp: {
siteId: 'site_id',
},
push: {
android: {
pushClickBehavior: PushClickBehaviorAndroid.ResetTaskStack
}
}
};
CustomerIO.initialize(config)
}, [])
}
Option | Type | Default | Description |
---|---|---|---|
cdpApiKey | string | Required: the key you'll use to initialize the SDK and send data to Customer.io | |
migrationSiteId | string | Required if you're updating from 3.x: the credential for previous versions of the SDK. This key lets the SDK send remaining tasks to Customer.io when your audience updates your app. | |
region | CioRegion.EU or CioRegion.US | CioRegion.US | Requires the CioRegion package. You must set the region your account is in the EU (CioRegion.EU ). |
autoTrackDeviceAttributes | boolean | true | Automatically gathers information about devices, like operating system, device locale, model, app version, etc |
trackApplicationLifecycleEvents | boolean | true | Set to false if you don't want the app to send lifecycle events |
logLevel | string | error | Requires the CioLogLevel package. Sets the level of logs you can view from the SDK. Set to debug or info to see more logging output. |
inApp | object | Required for in-app support. This object takes a siteId property, determining the workspace your in-app messages come from. | |
push | object | Takes a single option called PushClickBehaviorAndroid . This object and option controls how your app behaves when your Android audience taps push notifications. |