The function of react native in the integration of Friendship Alliance statistics

Source: Internet
Author: User
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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.