SDK Integration React-Native
Jiny supports only Android Platform in React-Native and will be extending support to iOS soon
Pre-requisites
Jiny identifies a screen of native apps uniquely with resource-id
and tag
property of an element in that screen. In react-native resource-id
is auto generated at run time it is not reliable to identify a screen using resource-id
. But tag
is not auto generated, rather needs to be added manually. It is used in testing frameworks like Espresso to identify the elements uniquely during testing. To tag elements you need add an attribute called testID
in the element. ReactNative converts testID
attribute into tag
attribute.
Here are some resources
You'll need to tag most of the views which will enable Jiny to identify the screen uniquely. To enable tagging UI elements use the below code.
1. Integration
Download jiny-react-native
package from npm using the following command
1.a Automatic Installation
If you are using React Native 0.60+
React native already has a feature called CLI autolink feature that links the module while building the app.
If you are using React Native <= 0.59
To link jiny-react-native
package automatically using the following command
1.b Manual Installation
Incase the Automatic Installation fails, you can link jiny-react-native
package manually
Open up
android/app/src/main/java/[...]/MainApplication.java
Add
import com.jiny.reactnative.JinyReactNativePackage;
to the imports at the top of the fileAdd
new JinyReactNativePackage()
to the list returned by thegetPackages()
method
Append the following lines to
android/settings.gradle
:Insert the following lines inside the dependencies block in
android/app/build.gradle
:
2. Initialization
To initialize Jiny add the following inside componentDidMount() {}
in your App.js
3. Web Support
If your app has any webview, tag your webview with a uinque testID and call this function in componentDidMount() {}
For tagging webview with unique testID refer below code
4. Disable Jiny
In case you want to disable Jiny, you can call this method
5. [Optional] User Identification
If you are using any other user identification other than google ad id, call this method
To get deeper analytics insights, use the above function.
6. Proguard Rules
If you are using proguard for your builds, add the following rules in android/proguard-rules.pro
file.
7. Callbacks
You can listen to the events provided by Jiny SDK by attaching a listener to DeviceEventEmitter with JinyCallbacks. (Make sure to call this method after you have initialised Jiny). Event is an Object with key as name of the event(String) and value as an Object of meta data of the event(Map<String, String>). For more on events refer this doc here.
Last updated