Android Quick access

Last updated:2025-01-13
Android Quick access

This article aims to guide users to quickly integrate push services. Please refer to the detailed integration steps. SDK Integration Guide and Manufacturer channel SDK Integration Guide

SDK For download details, see Resource download

Add project configuration

Project root directory master gradle Configuration

confirm Android Studio of Project root directory master gradle configured in mavenCentral Support (new Project Supported by default configuration), configure Huawei and FCM Maven Code base, available based on Huawei and FCM Released version updates select the latest version:

buildscript { repositories { google() mavenCentral() // hms, 若不集成华为厂商通道,可直接跳过 maven { url 'https://developer.huawei.com/repo/'} // fcm, 若不集成 FCM 通道,可直接跳过 maven { url "https://maven.google.com" } } dependencies { // fcm,若不集成 FCM 通道,可直接跳过 classpath 'com.google.gms:google-services:4.3.8' // hms,若不集成华为厂商通道,可直接跳过 classpath 'com.huawei.agconnect:agcp:1.6.0.300' } } allprojects { repositories { google() mavenCentral() //hms,若不集成华为厂商通道,可直接跳过 maven {url 'https://developer.huawei.com/repo/'} //fcm,若不集成 FCM 通道,可直接跳过 maven { url "https://maven.google.com" } } }
          buildscript {
                repositories {
                    google()
                    mavenCentral()
                    // hms, 若不集成华为厂商通道,可直接跳过
                    maven { url 'https://developer.huawei.com/repo/'}
                    // fcm, 若不集成 FCM 通道,可直接跳过
                    maven { url "https://maven.google.com" }
                  }

                 dependencies {
                    // fcm,若不集成 FCM 通道,可直接跳过
                    classpath 'com.google.gms:google-services:4.3.8'
                    // hms,若不集成华为厂商通道,可直接跳过
                    classpath 'com.huawei.agconnect:agcp:1.6.0.300'
                 }
             }

            allprojects {
                  repositories {
                    google()
                    mavenCentral()
                    //hms,若不集成华为厂商通道,可直接跳过
                    maven {url 'https://developer.huawei.com/repo/'}
                    //fcm,若不集成 FCM 通道,可直接跳过
                    maven { url "https://maven.google.com" }
                  }
              }

        
This code block is shown in the floating window

Module of gradle Configuration

exist Module of gradle Add dependencies and AndroidManifest substitution variables, integratedJPush SDK and manufacturer channel SDK, where the manufacturer combination can select the required channel.

android { ...... defaultConfig { applicationId "com.xxx.xxx" //JPush 上注册的包名. ...... ndk { //选择要添加的对应 cpu 类型的 .so 库。 abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a' // 还可以添加 'x86', 'x86_64', 'mips', 'mips64' } manifestPlaceholders = [ JPUSH_PKGNAME : applicationId, //JPush 上注册的包名对应的 Appkey. JPUSH_APPKEY : "你的 Appkey ", //暂时填写默认值即可. JPUSH_CHANNEL : "developer-default", //若不集成厂商通道,可直接跳过以下配置 MEIZU_APPKEY : "MZ-魅族的APPKEY", MEIZU_APPID : "MZ-魅族的APPID", XIAOMI_APPID : "MI-小米的APPID", XIAOMI_APPKEY : "MI-小米的APPKEY", OPPO_APPKEY : "OP-oppo的APPKEY", OPPO_APPID : "OP-oppo的APPID", OPPO_APPSECRET : "OP-oppo的APPSECRET", VIVO_APPKEY : "vivo的APPKEY", VIVO_APPID : "vivo的APPID", HONOR_APPID : "Honor的APP ID", NIO_APPID : "蔚来的APP ID", ] ...... } repositories { flatDir { dirs 'libs' } } ...... } dependencies { ...... // 此处以JPush 5.6.0 版本为例,注意:从 5.0.0 版本开始可以自动拉取 JCore 包,无需另外配置 implementation 'cn.jiguang.sdk:jpush:5.6.0' //若不集成厂商通道,可直接跳过以下依赖 // 极光厂商插件版本与接入 JPush 版本保持一致,下同 // 接入华为厂商 implementation 'com.huawei.hms:push:6.13.0.300' implementation 'cn.jiguang.sdk.plugin:huawei:5.6.0' // 接入 FCM 厂商 implementation 'com.google.firebase:firebase-messaging:24.1.0' implementation 'cn.jiguang.sdk.plugin:fcm:5.6.0' // 接入魅族厂商 implementation 'cn.jiguang.sdk.plugin:meizu:5.6.0' // JPush Android SDK v5.2.3 开始,需要单独引入 魅族 厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/meizu/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下 implementation(name: 'push-internal-5.0.3', ext: 'aar') // 接入 VIVO 厂商 implementation 'cn.jiguang.sdk.plugin:vivo:5.6.0' // 接入小米厂商 implementation 'cn.jiguang.sdk.plugin:xiaomi:5.6.0' // 接入 OPPO 厂商 implementation 'cn.jiguang.sdk.plugin:oppo:5.6.0' // JPush Android SDK v4.6.0 开始,需要单独引入 oppo 厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/oppo/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下 implementation(name: 'com.heytap.msp_3.5.3', ext: 'aar') //以下为 OPPO 3.1.0 aar需要依赖 implementation 'com.google.code.gson:gson:2.10.1' implementation 'commons-codec:commons-codec:1.6' implementation 'androidx.annotation:annotation:1.1.0' // 接入荣耀厂商 implementation 'cn.jiguang.sdk.plugin:honor:5.6.0' //需要单独引入荣耀厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/honor/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下 implementation(name: 'HiPushSDK-8.0.12.307', ext: 'aar') // 接入蔚来厂商 implementation 'cn.jiguang.sdk.plugin:nio:5.6.0' //JPush Android SDK v5.6.0 开始需要单独引入蔚来厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/nio/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下 implementation(name: 'niopush-sdk-v1.0', ext: 'aar') ...... } apply plugin: 'com.google.gms.google-services' apply plugin: 'com.huawei.agconnect'
          android {
                ......
                defaultConfig {
                    applicationId "com.xxx.xxx" //JPush 上注册的包名.
                    ......

                    ndk {
                        //选择要添加的对应 cpu 类型的 .so 库。
                        abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
                        // 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
                    }

                    manifestPlaceholders = [
                        JPUSH_PKGNAME : applicationId,
                        //JPush 上注册的包名对应的 Appkey.
                        JPUSH_APPKEY : "你的 Appkey ", 
                        //暂时填写默认值即可.
                        JPUSH_CHANNEL : "developer-default",

                        //若不集成厂商通道,可直接跳过以下配置
                        MEIZU_APPKEY : "MZ-魅族的APPKEY",
                        MEIZU_APPID : "MZ-魅族的APPID",
                        XIAOMI_APPID : "MI-小米的APPID",
                        XIAOMI_APPKEY : "MI-小米的APPKEY",
                        OPPO_APPKEY : "OP-oppo的APPKEY",
                        OPPO_APPID : "OP-oppo的APPID",
                        OPPO_APPSECRET : "OP-oppo的APPSECRET",
                        VIVO_APPKEY : "vivo的APPKEY",
                        VIVO_APPID : "vivo的APPID",
                        HONOR_APPID : "Honor的APP ID", 
                        NIO_APPID : "蔚来的APP ID", 
                    ]
                    ......
                }
                repositories {
                    flatDir {
                        dirs 'libs'
                    }
                }       
                ......
            }


            dependencies {
                ......
                // 此处以JPush 5.6.0 版本为例,注意:从 5.0.0 版本开始可以自动拉取 JCore 包,无需另外配置
                implementation 'cn.jiguang.sdk:jpush:5.6.0'  
                
                //若不集成厂商通道,可直接跳过以下依赖
                // 极光厂商插件版本与接入 JPush 版本保持一致,下同
                // 接入华为厂商
                implementation 'com.huawei.hms:push:6.13.0.300'
                implementation 'cn.jiguang.sdk.plugin:huawei:5.6.0'
                
                // 接入 FCM 厂商
                implementation 'com.google.firebase:firebase-messaging:24.1.0'
                implementation 'cn.jiguang.sdk.plugin:fcm:5.6.0'
                
                // 接入魅族厂商
                implementation 'cn.jiguang.sdk.plugin:meizu:5.6.0'
                 // JPush Android SDK v5.2.3 开始,需要单独引入 魅族 厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/meizu/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下
                implementation(name: 'push-internal-5.0.3', ext: 'aar')
                
                // 接入 VIVO 厂商
                implementation 'cn.jiguang.sdk.plugin:vivo:5.6.0'
                
                
                // 接入小米厂商
                implementation 'cn.jiguang.sdk.plugin:xiaomi:5.6.0'
                
                // 接入 OPPO 厂商
                implementation 'cn.jiguang.sdk.plugin:oppo:5.6.0'
                // JPush Android SDK v4.6.0 开始,需要单独引入 oppo 厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/oppo/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下
                implementation(name: 'com.heytap.msp_3.5.3', ext: 'aar')
                //以下为 OPPO 3.1.0 aar需要依赖
                implementation 'com.google.code.gson:gson:2.10.1'
                implementation 'commons-codec:commons-codec:1.6'
                implementation 'androidx.annotation:annotation:1.1.0'
                
                // 接入荣耀厂商
                implementation 'cn.jiguang.sdk.plugin:honor:5.6.0' 
                //需要单独引入荣耀厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/honor/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下
                implementation(name: 'HiPushSDK-8.0.12.307', ext: 'aar')
                
                // 接入蔚来厂商
                implementation 'cn.jiguang.sdk.plugin:nio:5.6.0' 
                //JPush Android SDK v5.6.0 开始需要单独引入蔚来厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/nio/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下
                implementation(name: 'niopush-sdk-v1.0', ext: 'aar')
                ......
            }

            apply plugin: 'com.google.gms.google-services'
            apply plugin: 'com.huawei.agconnect'

        
This code block is shown in the floating window

application Module Configuration

If the selected manufacturer channel contains Huawei manufacturer channel and FCM For the manufacturer channel, you need to perform the following additional operations. If not selected, you can ignore this step.
FCM:exist Firebase Create and JPush For the application to be released with the same package name as above, download the application after it is created. google-services.json configuration file and add it to the application's module directory.
Huawei:exist Huawei Create and JPush For the application to be released with the same package name as above, download the application after it is created. agconnect-services.json configuration file and add it to the application's module directory.

Configure push required components

exist AndroidManifest Configure one in Service and Receiver, to obtain more stable support on more mobile phone platforms, examples are as follows:

<!-- Since JCore2.0.0 Required SDK核心功能--> <!-- 可配置android:process参数将Service放在其他进程中;android:enabled属性不能是false --> <!-- 这个是自定义Service,要继承极光JCommonService,可以在更多手机平台上使得推送通道保持的更稳定 --> <service android:name="xx.xx.XService" android:enabled="true" android:exported="false" android:process=":pushcore"> <intent-filter> <action android:name="cn.jiguang.user.service.action" /> </intent-filter> </service> <!-- 新的 tag/alias 接口结果返回需要开发者配置一个自定义的Receiver --> <!-- 该广播需要继承 JPush 提供的 JPushMessageReceiver 类, 并如下新增一个 Intent-Filter --> <receiver android:name="自定义 Receiver" android:enabled="true" android:exported="false" > <intent-filter> <action android:name="cn.jpush.android.intent.RECEIVER_MESSAGE" /> <category android:name="您应用的包名" /> </intent-filter> </receiver>
          <!-- Since JCore2.0.0 Required SDK核心功能-->
<!-- 可配置android:process参数将Service放在其他进程中;android:enabled属性不能是false -->
<!-- 这个是自定义Service,要继承极光JCommonService,可以在更多手机平台上使得推送通道保持的更稳定 -->
<service android:name="xx.xx.XService"
        android:enabled="true"
        android:exported="false"
        android:process=":pushcore">
        <intent-filter>
            <action android:name="cn.jiguang.user.service.action" />
        </intent-filter>
</service>

<!-- 新的 tag/alias 接口结果返回需要开发者配置一个自定义的Receiver -->
<!-- 该广播需要继承 JPush 提供的 JPushMessageReceiver 类, 并如下新增一个 Intent-Filter -->
<receiver
    android:name="自定义 Receiver"
    android:enabled="true"
    android:exported="false" >
    <intent-filter>
            <action android:name="cn.jpush.android.intent.RECEIVER_MESSAGE" />
            <category android:name="您应用的包名" />
    </intent-filter>
</receiver>

        
This code block is shown in the floating window

Initialize push service

JPush SDK provided API Interfaces are mainly concentrated oncn.jpush.android.api.JPushInterfaceIn the category.

public class ExampleApplication extends Application { @Override public void onCreate() { super.onCreate(); JPushInterface.setDebugMode(true); // 调整点一:调用启用推送业务功能代码前增加setAuth调用 boolean isPrivacyReady; // app根据是否已弹窗获取隐私授权来赋值 if(!isPrivacyReady){ // JCore 5.0.4之前版本需要显式设置false if (JCoreInterface.getJCoreSDKVersionInt() < 504) { // 5.0.4版本号对应504 JCollectionAuth.setAuth(context, false); } // 所有版本在未授权时都不应初始化SDK return; } JPushInterface.init(); // 调整点二:App用户同意了隐私政策授权,并且开发者确定要开启推送服务后调用 // JCore 5.0.4+会自动处理授权状态,可不需要显式设置true JCollectionAuth.setAuth(context, true); } }
          public class ExampleApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        JPushInterface.setDebugMode(true);

      // 调整点一:调用启用推送业务功能代码前增加setAuth调用
      boolean isPrivacyReady; // app根据是否已弹窗获取隐私授权来赋值
      if(!isPrivacyReady){
        // JCore 5.0.4之前版本需要显式设置false
        if (JCoreInterface.getJCoreSDKVersionInt() < 504) { // 5.0.4版本号对应504
          JCollectionAuth.setAuth(context, false);
        }
        // 所有版本在未授权时都不应初始化SDK
        return;
      }
      JPushInterface.init();

      // 调整点二:App用户同意了隐私政策授权,并且开发者确定要开启推送服务后调用
      // JCore 5.0.4+会自动处理授权状态,可不需要显式设置true
      JCollectionAuth.setAuth(context, true);
    }
}


        
This code block is shown in the floating window

Verify push results

  • After the integration is completed, if the following log is output, it means that you have successfully integrated.
D/JIGUANG-JPush: [ActionHelper] doAction:init ...... I/JIGUANG-JCore: [ConnectingHelper] Register succeed - juid:58446897155, registrationId:1104a89792620fb0b02, deviceId:null
          D/JIGUANG-JPush: [ActionHelper] doAction:init
......
I/JIGUANG-JCore: [ConnectingHelper] Register succeed - juid:58446897155, registrationId:1104a89792620fb0b02, deviceId:null

        
This code block is shown in the floating window
  • Get the log registrationId, and inJiguangconsole Create push Experience push service.
  • After the push is completed, you can Push history View detailed data such as push status, push channel, delivery rate, etc.
Was this document helpful?

Copyright 2011-2026, jiguang.cn, All Rights Reserved. 粤ICP备12056275号-13 Shenzhen Hexun Huagu Information Technology Co., Ltd.

Open in Docs Center