1、前往官网注册应用
2、添加依赖
//极光统计
implementation 'cn.jiguang.sdk:jmessage:2.9.0'
implementation 'cn.jiguang.sdk:jcore:2.1.6'
3、配置APPID
位置app下的build.gradle文件中的android->defaultConfig中,AppKey创建好应用后查找,如下图
//清单文件替换配置
manifestPlaceholders = [
//JPush上注册的包名对应的appkey.
JPUSH_APPKEY : "8fcfb19950eae21f952100e8",
//暂时填写默认值即可.
JPUSH_CHANNEL: "developer-default",
//包名
JPUSH_PKGNAME: "com.example.charitable"
]
4、创建Service
/**
* JCore2.0.0及以上版本需要添加这个service
* 这个Service要继承JCommonService
*/
public class JiGuangService extends JCommonService {
}
5、配置Service
<!-- JCore2.0.0及以上版本需要添加这个service
这个Service要继承JCommonService -->
<service android:name=".service.JiGuangService"
android:process=":pushcore">
<intent-filter>
<action android:name="cn.jiguang.user.service.action" />
</intent-filter>
</service>
6、初始化SDK
//初始化极光IM
JMessageClient.init(getApplicationContext());
//注册极光消息回调
JMessageClient.registerEventReceiver(this);