1. Integration Preparation
First of all, we need to apply for a developer account at the Union website. Then create an application and get the Appkey.
2. Integrated SDK
After we get to Appkey, we will then integrate the Integrated SDK.
Android
The alliance supports the Androidstudio gradle configuration, so we use Androidstudio to open the Android directory under the React native project root directory as shown:
Then add the following in the/android/app/build.gradle:
dependencies {
compile ' com.umeng.analytics:analytics:latest.integration '
}
If integration does not work, add the following code:
allprojects {
repositories {
mavencentral ()
}
}
Then rebuild the application and Gradle will automatically download the configured SDK to local
3. Integrated configuration Android
Configure Androidmanifest.xml
Manifest configuration mainly includes adding permissions, the following permissions are indispensable, fill in the Appkey and fill in the channel ID three parts, code examples are as follows:
<manifest......>
<uses-sdk android:minsdkversion= "8" ></uses-sdk>
<uses-permission Android:name= "Android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name= " Android.permission.ACCESS_WIFI_STATE "/>
<uses-permission android:name=" Android.permission.INTERNET " >
<uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>
<application ......> .....
<activity ....../>
<meta-data android:value= "Your_app_key" android:name= "UMENG_APPKEY"/>
< Meta-data android:value= "Channel ID" android:name= "Umeng_channel"/>
</application>
</ Manifest>
The Your_app_key in the above code for Appkey needs to be replaced with the application Appkey,channel ID for you application in the league background is the extension channel name, which can be customized as needed, such as: GooglePlay most basic use
Once the above configuration is complete, we can use the statistical SDK. We only need to add the following code in the Mainactivity.java to complete the session statistics.
public void Onresume () {
super.onresume ();
Mobclickagent.onresume (this);
}
public void OnPause () {
super.onpause ();
Mobclickagent.onpause (this);
}
4. View
In the League my product page will be able to see the relevant data statistics