Android ten minutes fast automatic integration of Aurora push

Android ten minutes fast automatic integration of Aurora push

Aurora push is divided into manual integration and automatic integration. Manual integration is much more complex, so automatic integration is adopted. The official integration document is https://docs.jiguang.cn/jpush/client/Android/android_guide/
Note: for developers who use jcenter to automatically integrate, they do not need to add jar s and so in the project, and jcenter will automatically complete the dependency; in AndroidManifest.xml, they do not need to add any JPush SDK related configuration, and jcenter will automatically import. The construction of the project is very simple. Look at the catalog and it will be clear


1, Before integration, confirm that jcenter support is configured in the main gradle of android studio's project root directory. (supported for new project default configuration)
buildscript {
    repositories {
        jcenter()
    }
    ......
}

allprojets {
    repositories {
        jcenter()
    }
}
2, Add the following configuration dependency in the module's gradle
android {
    ......
    defaultConfig {
        applicationId "com.xxx.xxx" //Package name registered on JPush

        ndk {
            //Select the. so Library of the corresponding cpu type to add.
            abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a','x86'
            // You can also add 'x86', 'x86_', 'MIPS',' MIPS64 '
        }

        manifestPlaceholders = [
            JPUSH_PKGNAME : applicationId,
            JPUSH_APPKEY : "Your appkey", //The appkey corresponding to the package name registered on JPush
            JPUSH_CHANNEL : "developer-default", //Fill in the default value temporarily
        ]
    }
}

dependencies {
    compile 'cn.jiguang.sdk:jpush:3.1.1'  // Take jpush version 3.1.1 as an example.
    compile 'cn.jiguang.sdk:jcore:1.1.9'  // Take jcore version 1.1.9 as an example.
}
3, Add permission in the manifest file AndroidMainfest.xml
<!-- Required -->
    <uses-permission android:name="palmartourism.iwiteks.www.jiguangtest.permission.JPUSH_MESSAGE" />
    <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <!-- Optional. Required for location feature -->
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- For opening debug Version 6.0 System Cascade window permission -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_TASKS" />
4, Call in Activity
JPushInterface.setDebugMode(true);//If the official version is changed to false
JPushInterface.init(this);
5, Test, the server will also write, but the test is temporarily tested with the aurora client


Tags: Android SDK xml Gradle

Posted on Sun, 03 May 2020 20:35:35 -0400 by monkey72