Setting Up React Native SDK
This article provides step-by-step instructions for adding the Ditto npm package to your project, importing and initializing Ditto, and preparing React Native apps targeting iOS and Android for usage with the Ditto SDK.
The Ditto SDK is designed for apps built with bare React Native CLI; apps created with Expo-specific configurations may not be fully compatible.
If you have an Expo-built React Native project you want to integrate with Ditto, you may need to generate native source code for Android and iOS by prebuilding your project. For more information, see the official Expo documentation for Prebuild.
Open your iOS Info.plist as source code and make sure it contains the following lines (hint: you can right-click on the file in Xcode and find this option). These keys enable your app to use Bluetooth and local network services, which are required for Ditto to sync with nearby devices.
You can customize the corresponding string keys as you wish, but having them populated is mandatory.
Add the Uses Bluetooth LE accessories and Acts as a Bluetooth LE accessory as Background Modes.
Update Android's minimum SDK version to 24 or higher. This property is found in android/gradle.properties for newer projects.
Add permissions and headers to your main AndroidManifest. These additions request network and location access permissions required for Ditto to connect to nearby devices. This file is usually found under android/app/src/main:
If you encounter the Execution failed for task ':app:mergeDebugNativeLibs’ [...] 2 files found with path 'lib//libjsi.so' (mostly when running on the old architecture), add the following to your app android/app/build.gradle: