Loading…

Packages and Configuration Options

Updated

How it works

With our Expo plugin, you’ll add configuration options in two places:

  1. In your app.json or app.config.js files, you’ll add configuration options that affect the native files we generate when you run the prebuild.
  2. 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 or app.config.js files. Before you set up your app:

  • Note the ios.pushNotification.env.region. If you’re in our EU region, you’ll need to set this value to eu.
  • To support Cusotmer.io’s latest features, you’ll also want to set your iOS deployment target to 15.1 or higher.

If you send notifications to iOS users through Firebase Cloud Messaging, you’ll need to:

  • Set expo-build-properties.ios.useFrameworks to static.
  • Set customerio-expo-plugin.ios.pushNotification.provider to fcm.
  • Set customerio-expo-plugin.ios.pushNotification.googleServicesFile to the location of your GoogleService-Info.plist file. If you use @react-native-firebase with the Customer.io SDK, you should not set this value Learn more
{
   "plugins": [
      [
         "expo-build-properties",
         {
            "ios": {
               "deploymentTarget": "15.1", // set your iOS deployment target to support Customer.io
               "useFrameworks": "static" // set if you use FCM to send push notifications to iOS devices
            }
         }
      ],
      [
         "customerio-expo-plugin",
         {
            "android": {
               "googleServicesFile": "./files/google-services.json"
            },
            "ios": {
               "pushNotification": {
                  "provider": "fcm", // use "apn" for Apple Push Notification service
                  "googleServicesFile": "<Path to GoogleService-Info.plist file>", // required if provider is "fcm" and you don't use the @react-native-firebase SDK
                  "useRichPush": true,
                  "env": {
                     "cdpApiKey": "<apiKey>",
                     "region": "us"
                  }
               }
            }
         }
      ]
   ]
}
OptionTypeDefaultDescription
androidobjectRequired if you want to setup Android even if it is empty. Eg ("android": {}).
android.googleServicesFilestringSet the path to your google-services.json file.
android.setHighPriorityPushHandlerbooleanThis is optional, if you choose to use a 3rd party plugin to handle notification permissions, but want our SDK to handle the notifications.
iosobjectRequired: The parent object for iOS settings, including your initialization keys.
ios.pushNotificationobjectRequired Enables push notifications for iOS.
ios.pushNotification.autoFetchDeviceTokenbooleantrueWhen true, the SDK automatically gets the device token. But, if you get tokens through another provider and register them with the SDK using the CustomerIO.registerDeviceToken method, you should set this to false. Learn more
ios.pushNotification.providerstringapnUse apn for Apple Push Notification service or fcm for Firebase Cloud Messaging.
ios.pushNotification.googleServicesFilestringRequired if ios.pushNotification.provider is fcm. Set the path to your GoogleService-Info.plist file. Do not set this value if you use the @react-native-firebase SDK. Learn more
ios.pushNotification.useRichPushbooleanfalseEnables rich push features for iOS (images and links).
ios.pushNotification.envobjectRequired Contains your API key (env.cdpApiKey) and region (env.region with one of eu or us) information.
ios.pushNotification.env.regionus or euusThe region your Customer.io account is in. If you use the wrong region, your mobile traffic won’t make it into Customer.io.
ios.useFrameworksstring(Optional) Allows the plugin to work with static libraries. Options are static and dynamic
ios.disableNotificationRegistrationbooleantrue(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.showPushAppInForegroundbooleantrueSet to true if you want push notifications sent by Customer.io to be shown when your app is in the foreground.
ios.handleDeeplinkInKilledStatebooleanfalseSet 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 ProductRequired?Description
CustomerIOThe main SDK package. Used to initialize the SDK and call the SDK’s methods.
CioConfigConfigure the SDK including in-app messaging support.
CioRegionUsed inside the CioConfig.region option to declare your region—EU or US.
CioLogLevelUsed 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.ActivityPreventRestart
         }
      }
   };
   CustomerIO.initialize(config)
   }, [])
}
OptionTypeDefaultDescription
cdpApiKeystringRequired: the key you'll use to initialize the SDK and send data to Customer.io
migrationSiteIdstringRequired 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.
regionCioRegion.EU or CioRegion.USCioRegion.USRequires the CioRegion package. You must set the region your account is in the EU (CioRegion.EU).
autoTrackDeviceAttributesbooleantrueAutomatically gathers information about devices, like operating system, device locale, model, app version, etc
screenViewUseAll or InAppAllScreenView.All (Default): Screen events are sent to Customer.io. You can use these events to build segments, trigger campaigns, and target in-app messages.

ScreenView.InApp: Screen view events not sent to Customer.io. You’ll only use them to target in-app messages based on page rules.
trackApplicationLifecycleEventsbooleantrueSet to false if you don't want the app to send lifecycle events
logLevelstringerrorRequires the CioLogLevel package. Sets the level of logs you can view from the SDK. Set to debug or info to see more logging output.
inAppobjectRequired for in-app support. This object takes a siteId property, determining the workspace your in-app messages come from.
pushobjectTakes a single option called PushClickBehaviorAndroid. This object and option controls how your app behaves when your Android audience taps push notifications.
Copied to clipboard!
  Contents
Current release
 2.0.0-beta.2
Is this page helpful?