创建应用
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"