Guides
Guides

React Native Auto Integration

How to add the Marigold React Native SDK using auto integration

From v9.0.0 of the SDK, we have added for support for auto integration. If you are using an older version or want to make manual changes to the integration, see our legacy integration doc here.

Add the SDK

First add the SDK to your project:

npm i react-native-marigold
yarn add react-native-sailthru-mobile

iOS

Navigate to the ios folder of the app and run cocopods install to link the iOS dependencies:

cd ios; pod install; cd ..

Android

Open the app level build.gradle and add the Marigold maven repo:

repositories {
    maven {
        url "https://github.com/sailthru/maven-repository/raw/master/"
    }
}

This allows the React Native SDK to pull in the native Android SDK dependency.

For more details about auto linking, see the React Native auto linking description here


Start the SDK

You will now need to add the startEngine call using the native SDKs. This should be done as early as possible in your app startup in order to ensure the SDK is properly integrated with the app.


iOS

See the iOS integration guide here for details.


Android

See the Android integration guide here for details.


R8/Proguard

The Android SDK makes use of Retrofit for its internal networking, which in turn makes use of reflection. This can be impacted by R8/Proguard in production builds of your RN Android app, which strips out unused symbols. This leads to unusual errors when attempting to use the SDK:

Error

Marigold Registration Error java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType This can be resolved by adding the Retrofit rules to your app's proguard-rules.pro, as recommended in their README.

Note that Android recommends against including some of these rules in library consumer keep rules, which is why they need to be added manually to the app rules.