React Native integration
Apptics' React Native SDK is a wrapper around Apptics' native iOS and Android SDK. At the moment, Apptics' React Native SDK supports the below mentioned modules:
- Crash reporting and analytics
- In-app events
- Screens
- Sessions
- Remote logger
- Remote configurations
- In-app updates
Install Apptics
Prerequisites
- Requires React Native v0.6 and above.
- You need to complete the setup for development environment for React Native.
- Under your app's root directory install Apptics' React Native SDK.
Copiednpm install @zoho_apptics/apptics-react-native
Initialize Apptics
You need to perform the platform-specific initialization steps.
Apple
- Register your app in the Apptics console and download the apptics-config.plist. Refer to our user guide here.
- Once downloaded, place the file in the root of your iOS app at ios/[YOUR APP NAME]/apptics-config.plist.
- Make sure that the apptics-config.plist file is added to your project in Xcode.
- Add the pre-build script to the podfile.
To add a run script via the podfile, use the below.
Copiedsource 'https://github.com/CocoaPods/Specs.git'
target 'MAIN TARGET' do
# Pre build script will register the app version, upload dSYM file to the server and add apptics specific information to the main info.plist which will be used by the SDK.
script_phase :name => 'Apptics pre build', :script => 'sh "./Pods/Apptics-SDK/scripts/run" --upload-symbols-for-configurations="Release, Appstore"', :execution_position => :before_compile
end
You can also add the run script manually. Follow the below steps.
- Select your project in the project navigator.
- Select the target you want to modify.
- Click on Build phases. Click the + icon and choose the New Run Script Phase from the pop-up. Rename the new run script phase as Apptics pre build.
- Click on the disclosure triangle for the newly added run script phase.
- In the shell text field add the below script.
sh "./Pods/Apptics-SDK/scripts/run" --upload-symbols-for-configurations="Release, Appstore"
Important:
- Adding the pre-build script is mandatory.
- In the pre-build script, we upload dSYM to the server (optional), register the app with the Apptics server, and add the necessary information of the app version into the apptics-config.plist. Which is then used by the SDK to send the data to the Apptics server.
- Always make sure the 'Copy Bundle Resources' is below the 'Compile Sources' and 'Apptics pre build' is above the 'Compile Sources'.
Build script usage:
run --upload-symbols-for-configurations="Release, Appstore" --config-file-path="YOUR_PATH/apptics-config.plist" --app-group-identifier="group.com.company.application [Optional]"
- --config-file-path pass your config file path if it is not added to your project root.
- --app-group-identifier if you have enabled app group identifier for your app's target.
- --upload-symbols-for-configurations string, an optional parameter to pass your configuration name debug, release, or add a custom name with comma-separated for which the dSYMs will be uploaded without any prompt during App Store submission process via CI, CT, and CD.
- For more details on how to configure multiple projects refer the SDK guide.
- Build the Xcode project and check for any issues. Skip to events tracking.
Android
- Register your app in the Apptics console and download the apptics-config.plist. Refer to our User guide here.
- Place apptics-config.json file in the app/ directory (Root of the Android Studio app module).
- Add apptics-plugin classpath and zoho maven url in the project level build.gradle
Copiedbuildscript {
repositories {
maven {
url "https://maven.zohodl.com/"
}
}
dependencies {
classpath "com.zoho.apptics:apptics-plugin:0.1.2"
}
}
allprojects {
repositories {
maven {
url "https://maven.zohodl.com/"
}
}
}
- Apply apptics-plugin in your app level build.gradle file (android/app/build.gradle).
Copiedapply plugin: "com.android.application"
apply plugin: "apptics-plugin"
- Initialize Apptics in JS.
Copiedimport { Apptics } from '@zoho_apptics/apptics-react-native';
Apptics.init();