1、极光推送配置文档地址:
https://docs.jiguang.cn/jpush/client/Android/android_guide
采用 jcenter 自动集成。
2、build.gradle(app)
a、在defaultConfig的:
ndk {
//选择要添加的对应 cpu 类型的 .so 库。
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86'
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
}
manifestPlaceholders = [
JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.
]
b、多渠道配置不同的JPUSH_PKGNAME、JPUSH_APPKEY
flavorDimensions "jpush"
productFlavors {
Demo1 {
applicationIdSuffix ".demo1"
manifestPlaceholders = [label: '极光1', JPUSH_PKGNAME: 'com.jpush.demo1', JPUSH_APPKEY: '8db5a8ad9a6e2d21f7488dfb']
}
Demo2 {
applicationIdSuffix ".demo2"
manifestPlaceholders = [label: '极光2', JPUSH_PKGNAME: 'com.jpush.demo2', JPUSH_APPKEY: 'c67f605c51a5b176cb61102d']
}
Demo3 {
applicationIdSuffix ".demo3"
manifestPlaceholders = [label: '极光3', JPUSH_PKGNAME: 'com.jpush.demo3', JPUSH_APPKEY: '2cbe4e7b879f18b8dc1d422d']
}
}
3、在Application 中进行初始化
class MyApplication: Application() {
override fun onCreate() {
super.onCreate()
JPushInterface.setDebugMode(true)
JPushInterface.init(this)
}
}
4、在极光开发服务中创建对应的3个应用
WechatIMG15.jpeg
5、发送消息
WechatIMG14.jpeg WechatIMG16.jpeg WechatIMG17.jpeg
6、demo 地址:
https://github.com/youyou0101/JPushDemo.git
网友评论