React Native
Monterosa / Interaction SDK allows you to embed an Experience in your React Native app.
Getting started
Prerequisites
First of all, you'll need a React Native application into which you'll install the SDK. This guide assumes you have created it using a command similar to the one recommended by React Native's documentation:
npx create-expo-app MyAppIf that is the case, you'll need to generate the iOS and Android projects in order for the SDK to be installed. This can be done with the commands:
npx expo run:iosand
npx expo run:androidOnce this is done, you should have a folder structure that includes an ios and android folders.
Installation
The first step is to install the React Native SDK NPM package. This can be done with the following snippet (making sure to replace the package token provided):
npm config set @monterosa-sdk:registry https://gitlab.com/api/v4/projects/38419920/packages/npm/
npm config set //gitlab.com/api/v4/projects/38419920/packages/npm/:_authToken "<package token>"
npm install @monterosa-sdk/react-nativeAs a result of this command, your node_modules will include a package called @monterosa-sdk/react-native, which includes:
The Android code necessary to interact with the native Android SDK from React Native
The iOS counterpart to that code
The JavaScript wrapper code
You'll need to update your Android and iOS projects to link to the Android and iOS native SDKs.
Android Setup
In order to setup the Android app, you'll need to install the native SDKs. To do so, enter the following snippet in the android/settings.gradle file:
Once that is entered, the React Native SDK will be able to obtain the native SDK libraries required for it to operate.
Finally, you'll need to make sure that the minimum Android API level is set to 23, as opposed to the default 21 in the React Native setup. This can be achieved by updating the minSdkVersion value in android/build.gradle:
iOS Setup
Similarly to Android, we need to update the Podfile in ios/Podfile in order to be able to locate the native SDK libraries. This can be achieved by adding the following lines to the target of your app:
Note that the pods of the SDK need to be declared BEFORE the calls to use_expo_modules and use_native_modules occur.
Embedding an Experience
Once the installation is resolved, you can embed an Experience by using the next snippet:
Please note that when embedding an experience, the experienceUrl field is not required in the configuration and should not be set.
Events in the SDK
The SDK offers a onMessageReceived prop where a function can be passed to receive the messages from the native implementations. These messages cover from Messages sent from the Experience, to debug messages.
You can read more on this topic here.
SSO Integration with your IAM provider
Through Identify, Monterosa supports SSO integrations with a suite of IAM providers and has the capacity to create bespoke integrations when needed.
Pre-requisite
Please contact our sales team if you're interested in setting up the integration between your IAM provider, and Identify.
SSO via React Native SDK
Using the React Native SDK, you can pass a token to the MonterosaSdkExperienceView so that it is used to log-in the user within the Experience with a token property in the configuration.
To ensure the token is transmitted correctly, it must be set after the view has been initialized. To achieve this, update the configuration object with the token once the view is fully loaded. The following snippet demonstrates how this can be achieved:
Update the config with the token once the message didBecomeReady has been received. The token provided will be later submitted to Identify when attempting to log-in the user.
Additionally, we support a range of Identify Events documented here.
Login prompted by Experience
In many cases, Monterosa / Interaction Cloud encourages the sign-up of users to your platform via gated content. This is achieved by sending an event to the application when the user taps on a "Sign up" button in the UI of the Experience.
The following snippet outlines how to intercept the event:
Configure the Experience
The SDK allows for configuration and customisation of the Experience view through adjustable props, aligning with your app's specific needs.
You can read more on this available configuration options here
Sending messages to the Experience
In order to enable a seamless User Experience, it's often necessary to communicate with the Experience to share necessary information with the app. The SDK offers the capacity to send and receive messages following the next snippet:
Sending additional parameters to the Experience
Resizing Embedded Experiences using the React Native SDK
The Monterosa Web SDK supports automatic resizing of embedded content via the autoresizesHeight flag. This ensures that the Experience notifies its parent container (e.g. an iframe or wrapper) whenever its height changes, allowing for a seamless layout with no internal scroll bars or clipped content.
However, this functionality is not currently available in the React Native SDK.
When embedding an Experience inside a MonterosaSdkExperienceView in a React Native app, the container does not automatically adjust its height when the content inside the Experience changes. As a result, developers may observe issues such as:
Cropped content
Scrollbars appearing within the WebView
Extra spacing below or above the Experience
Available Workaround
To support dynamic sizing in React Native, Monterosa offers a custom workaround that can be implemented in the embedded Experience.
This approach involves:
Adding a
ResizeObserverinside the Experience to track changes to the layout (e.g. from user interaction, timers, or content updates)Sending a structured message via the SDK’s messaging interface when the size changes
Listening to that message in the React Native host using the
onMessageReceivedpropDynamically adjusting the height of the WebView based on the provided dimensions
⚠️ Note: This resizing behaviour is not built into the React Native SDK by default. It requires additional implementation within the Experience itself, and coordinated handling in the host app. If your use case requires this functionality, please consult with your Monterosa contact to determine feasibility and integration requirements.
Additional Parameters
Using the React Native SDK, you can pass additional parameters to the Experience when you create it. To do so, provide a dictionary in the parameter key of the configuration property in the MonterosaSdkExperienceView. This can come in useful for the initial configuration of the Experience, for instance, setting up the language to use:
Last updated

