安卓开发极光推送(自动集成)

本文详细介绍了如何在Android项目中集成极光推送服务,包括创建应用、配置Gradle、添加依赖及配置AndroidManifest.xml等步骤。

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

创建应用

1. 登录https://www.jiguang.cn/

2.访问https://www.jiguang.cn/dev/#/app/create 创建应用

 填写应用名称, 上传应用图标 

填写包名

本次采用Jenter的形式完成集成极光推送,好处就是可以自动省略很多配置。

确认 android studio 的 Project 根目录的主 gradle 中配置了 jcenter 支持。

buildscript {
    repositories {
		...
        jcenter()
        ...
    }
    ...
}
allprojects {
    repositories {
		...
        jcenter()
        ...
    }
}

在app 的build.gradle 中添加如下两个依赖

defaultConfig {
    applicationId "xxx.xxx.xxx"
    minSdkVersion 16
    targetSdkVersion 28
    versionCode 1
    versionName "1.1.0"
    flavorDimensions "default"
    multiDexEnabled true
    ndk {
        //设置支持的SO库架构
        abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'       //, 'x86', 'x86_64', 'arm64-v8a'
    }
   
    manifestPlaceholders = [
            JPUSH_PKGNAME : applicationId, //JPush上注册的包名.
            JPUSH_APPKEY : "your  AppKey", //JPush上注册的包名对应的appkey.
            JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.
    ]
}

 

在配置文件当中如下配置

 <!-- Required SDK 核心功能-->
        <!-- 可配置android:process参数将PushService放在其他进程中 -->
        <service
            android:name="cn.jpush.android.service.PushService"
            android:exported="false"
            tools:node="replace"
            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 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
        <!-- User defined.  For test only  你自定义的广播接收器 -->
        <receiver
            android:name=".MyReceiver"
            android:enabled="true"
            android:exported="false">
            <intent-filter>
                <action android:name="cn.jpush.android.intent.REGISTRATION" /> <!-- Required  用户注册SDK的intent -->
                <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <!-- Required  用户接收SDK消息的intent -->
                <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <!-- Required  用户接收SDK通知栏信息的intent -->
                <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <!-- Required  用户打开自定义通知栏的intent -->
                <action android:name="cn.jpush.android.intent.ACTION_RICHPUSH_CALLBACK" /> <!-- Optional 用户接受Rich Push Javascript 回调函数的intent -->
                <action android:name="cn.jpush.android.intent.CONNECTION" /> <!-- 接收网络变化 连接/断开 since 1.6.3 -->
                <category android:name="你的包名" />
            </intent-filter>
        </receiver>
        <!-- Required  . Enable it you can get statistics data with channel -->
        <meta-data
            android:name="JPUSH_CHANNEL"
            android:value="developer-default" />
        <!-- 测试AppKey -->
        <meta-data
            android:name="JPUSH_APPKEY"
            android:value="your  AppKey" />

不要添加其他的东西,会报以下错误

Manifest merger failed with multiple errors, see logs"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值