Android接入极光推送,接入华为,小米,OPPO,VIVO厂商通道

本文详细介绍了如何在Android应用中集成极光推送并接入华为、小米、OPPO、VIVO等厂商推送通道。主要内容包括配置AndroidManifest.xml,写自定义接收通知的类,以及针对各厂商的SDK集成步骤,以确保应用在不同状态下都能收到推送通知。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

 

极光推送作用:

        极光推送(JPush)是一个端到端的推送服务,使得服务器端消息能够及时地推送到终端用户手机上,让开发者积极地保持与用户的连接,从而提高用户活跃度、提高应用的留存率

主要作用:

       保持与服务器的长连接,以便消息能够即时推送到达客户端

      接收通知与自定义消息,并向开发者 App 传递相关信息

SDK 所支持的 Android 系统版本

       目前 SDK 只支持 Android 2.3 或以上版本的手机系统;

       富媒体信息流功能则需 Android 3.0 或以上版本的系统。

手动集成步骤:

手动集成压缩包下载链接:http://docs.jiguang.cn/jpush/resources/

  • 解压缩 jpush-android--3.x.x-release.zip 集成压缩包。
  • 复制 libs/jcore-android-x.x.x.jar 到工程 libs/ 目录下。
  • 复制 libs/jpush-android-3.x.x.jar 到工程 libs/ 目录下。
  • 复制 libs/(cpu-type)/libjcore1xy.so 到你的工程中存放对应 cpu 类型的目录下。
  • 复制 res/ 中 drawable-hdpi, layout, values 文件夹中的资源文件到你的工程中 res/ 对应同名的目录下。

共用了极光一键登入的jcore,就没有复制jcore-android-x.x.x.jar到lib下

说明 1:若没有 res/drawable-xxxx/jpush_notification_icon 这个资源默认使用应用图标作为通知 icon,在 5.0 以上系统将应用图标作为 statusbar icon 可能显示不正常,用户可定义没有阴影和渐变色的 icon 替换这个文件,文件名不要变。

说明 2:使用 android studio 的开发者,如果使用 jniLibs 文件夹导入 so 文件,则仅需将所有 cpu 类型的文件夹拷进去;如果将 so 文件添加在 module的libs 文件夹下,注意在 module 的 gradle 配置中添加一下配置:

sourceSets {
    main {
        jniLibs.srcDirs = ['libs']
        jniLibs.srcDirs = ['src/main/jniLibs']
        assets.srcDirs = ['src/main/assets', 'src/main/assets/']
    }
}

配置 AndroidManifest.xml

<receiver
    android:name=".message.JPushReceiver"
    android:enabled="true">
    <intent-filter android:priority="1000">
        <action android:name="cn.jpush.android.intent.REGISTRATION" />
        <!-- &lt;!&ndash; Required  用户注册SDK的intent &ndash;&gt; -->
        <action android:name="cn.jpush.android.intent.UNREGISTRATION" />
        <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" />
        <!-- &lt;!&ndash; Required  用户接收SDK消息的intent &ndash;&gt; -->
        <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />
        <!-- &lt;!&ndash; Required  用户接收SDK通知栏信息的intent &ndash;&gt; -->
        <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />
        <!-- &lt;!&ndash; Required  用户打开自定义通知栏的intent &ndash;&gt; -->
        <action android:name="cn.jpush.android.intent.ACTION_RICHPUSH_CALLBACK" />
        <!-- &lt;!&ndash; Optional 用户接受Rich Push Javascript 回调函数的intent &ndash;&gt; -->
        <action android:name="cn.jpush.android.intent.CONNECTION" />
        <!-- &lt;!&ndash; JPush 服务的连接状态发生变化。(注:不是指 Android 系统的网络连接状态。) 连接/断开 since 1.6.3 &ndash;&gt; -->
        <category android:name="**********" />
    </intent-filter>
</receiver> <!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
<!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 -->
<!-- Rich push 核心功能 since 2.0.6 -->
<activity
    android:name="cn.jpush.android.ui.PopWinActivity"
    android:exported="true">
    <intent-filter>
        <category android:name="android.intent.category.DEFAULT" />

        <action android:name="cn.jpush.android.ui.PopWinActivity" />

        <category android:name="${applicationId}" />
    </intent-filter>
</activity> <!-- Required SDK核心功能 -->
<activity
    android:name="cn.jpush.android.ui.PushActivity"
    android:configChanges="orientation|keyboardHidden"
    android:exported="true"
    android:theme="@android:style/Theme.NoTitleBar">
    <intent-filter>
        <action android:name="cn.jpush.android.ui.PushActivity" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="${applicationId}" />
    </intent-filter>
</activity> <!-- Required SDK 核心功能 -->
<!-- 可配置android:process参数将PushService放在其他进程中 -->
<service
    android:name="cn.jpush.android.service.PushService"
    android:exported="false"
    android:process=":pushcore">
    <intent-filter>
        <action android:name="cn.jpush.android.intent.REGISTER" />
        <action android:name="cn.jpush.android.intent.REPORT" />
        <action android:name="cn.jpush.android.intent.PushService" />
        <action android:name="cn.jpush.android.intent.PUSH_TIME" />
    </intent-filter>
</service> <!-- since 3.0.9 Required SDK 核心功能 -->
<provider
    android:name="cn.jpush.android.service.DataProvider"
    android:authorities="${applicationId}.DataProvider"
    android:exported="false"
    android:process=":pushcore" /> <!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
<!-- 若不启用该功能可删除该组件,或把 enabled 设置成 false ;App 不会被其他 App 拉起,但会拉起其他的 App。 -->
<service
    android:name="cn.jpush.android.service.DaemonService"
    android:enabled="true"
    android:exported="true">
    <intent-filter>
        <action android:name="cn.jpush.android.intent.DaemonService" />

        <category android:name="${applicationId}" />
    </intent-filter>
</service> <!-- 可选,如果使用静态Activity方式拉起,该组件必须声明 -->
<activity
    android:name="cn.jpush.android.service.DActivity"
    android:enabled="true"
    android:exported="true"
    android:taskAffinity="jpush.custom"
    android:theme="@android:style/Theme.Translucent.NoTitleBar">
    <intent-filter>
        <action android:name="cn.jpush.android.intent.DActivity" />

        <category android:name="${applicationId}" />
    </intent-filter>
</activity> <!-- since 3.1.0 Required SDK 核心功能 -->
<provider
    android:name="cn.jpush.android.service.DownloadProvider"
    android:authorities="${applicationId}.DownloadProvider"
    android:exported="true" /> <!-- Required SDK核心功能 -->
<receiver
    android:name="cn.jpush.android.service.PushReceiver"
    android:enabled="true">
    <intent-filter android:priority="1000">
        <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> <!-- Required  显示通知栏 -->
        <category android:name="${applicationId}" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.USER_PRESENT" />
        <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
    </intent-filter>
    <!-- Optional -->
    <intent-filter>
        <action android:name="android.intent.action.PACKAGE_ADDED" />
        <action android:name="android.intent.action.PACKAGE_REMOVED" />

        <data android:scheme="package" />
    </intent-filter>
</receiver> <!-- Required SDK核心功能 -->
<receiver
    android:name="cn.jpush.android.service.AlarmReceiver"
    android:exported="false" />
<!--
        &lt;!&ndash; 3.5.0新增,用于定时展示功能 &ndash;&gt;
        <receiver android:name="cn.jpush.android.service.SchedulerReceiver" android:exported="false"/>
-->
<receiver android:name=".message
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值