Expo - React Native
Overview
Getting started for apps that are built with Expo utilizing Continuous Native Generation (CNG) and Prebuild.
If you're not using Expo, CNG and Prebuild, you should follow the React Native docs instead.
Not sure what CNG is? Read more about CNG here.
Installation
-
Install the SDK
-
iOS - Update your
app.jsonto include theassociatedDomainsfor your MovableInk domain. Also update theinfoPlistto include the keys:movable_ink_universal_link_domains,movable_ink_api_key, andmovable_ink_region.Key Description scheme If you don't already have a custom URI scheme for your app, add one here. This is required to support deeplinking - a scheme of myappwould allow links such asmyapp://some/pathto open your app.movable_ink_universal_link_domains The list of MovableInk domains that will open your app. This should match any MovableInk applinks in associatedDomains- Required for using Universal Links | App Links | Deeplinksmovable_ink_api_key Your MovableInk SDK API Key - Required for using Behavior Events movable_ink_region Your MovableInk Region - Required for using Behavior Events -
Android - Update your
app.jsonto include theintentFiltersfor your MovableInk domain.{ "expo": { "android": { "intentFilters": [ { "action": "VIEW", "autoVerify": true, "data": [ { "scheme": "https", "host": "mi.domain.com", "pathPrefix": "/p/cpm" } ], "category": ["BROWSABLE", "DEFAULT"] }, { "action": "VIEW", "data": [ { "scheme": "https", "host": "mi.domain.com", "pathPrefix": "/p/rpm" } ], "category": ["BROWSABLE", "DEFAULT"] }, { "action": "VIEW", "data": [ { "scheme": "https", "host": "mi.domain.com", "pathPrefix": "/p/gom" } ], "category": ["BROWSABLE", "DEFAULT"] } ] } } }Make sure to update any instances of
mi.domain.comto match your MovableInk domain.You'll also need to add a plugin to set your API Key:
At the root of your project, create a folder called
pluginsif it doesn't already exist. In that plugins folder, create a file calledmi_plugin.jsAdd the following content:
// mi_plugin.js const { withAndroidManifest, withAppBuildGradle } = require('@expo/config-plugins'); module.exports = function movableInkPlugin(config, data) { // Handle AndroidManifest.xml config = withAndroidManifest(config, async (config) => { let androidManifest = config.modResults.manifest; // Handle application-level modifications if (androidManifest.application && androidManifest.application[0]) { const application = androidManifest.application[0]; // Initialize meta-data array if it doesn't exist if (!application['meta-data']) { application['meta-data'] = []; } // Handle Movable Ink API key if (data.movable_ink_android_api_key) { application['meta-data'].push({ $: { 'android:name': 'com.movableink.inked.API_KEY', 'android:value': data.movable_ink_android_api_key, }, }); } } return config; }); // Handle build.gradle config = withAppBuildGradle(config, (config) => { const { modResults } = config; if (data.movable_ink_android_region) { const region = data.movable_ink_android_region.toUpperCase(); // Add buildConfigField to defaultConfig const buildConfigField = `buildConfigField("String", "MOVABLE_INK_SDK_REGION", "\\"${region}\\"")`; // Find defaultConfig block and add the buildConfigField if (modResults.contents.includes('defaultConfig {')) { modResults.contents = modResults.contents.replace( /defaultConfig\s*\{/, `defaultConfig {\n ${buildConfigField}` ); } } return config; }); return config; };Update your
app.jsonto include the plugin: -
Run prebuild
-
Import RNMovableInk in your project and start the SDK as early as possible, such as in your
app/_layout.tsxfile:
For detailed information on specific features, please refer to the following sections:
Studio:
- Deeplinking - Learn how to handle MovableInk deeplinks in your Expo app
- Behavior Events - Track user behavior and interactions
- In App Message - Display interactive HTML-based in-app messages
DaVinci:
- Push Notifications - Handle push notification events
- Behavior Events - Track DaVinci-enabled behavior events
SDK Size
The MovableInk SDK adds approximately 0.5 MB to the compressed app size and 1.8 MB to the uncompressed app size. The "compressed app size" refers to the size of the app when it is packaged and compressed for distribution, such as when it is downloaded. Once downloaded, the app is decompressed and installed on the user's device. The uncompressed size is what actually occupies space on the device.