Android 腾讯信鸽集成
一:创建应用
信鸽官网可以直接使用QQ登录
点击个人信息—>我的应用—>新建应用
选择平台

填写配置

完成配置

二:开始在项目中配置
在app的build的文件中
在android里的defaultConfig里
//信鸽官网上注册的包名.注意application ID 和当前的应用包名以及 信鸽官网上注册应用的包名必须一致。
applicationId "你的包名"
ndk {
//根据需要 自行选择添加的对应cpu类型的.so库。
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
}
manifestPlaceholders = [
XG_ACCESS_ID:"注册应用的accessid",
XG_ACCESS_KEY : "注册应用的accesskey",
]
依赖
//信鸽普通版本jar,不包含厂商通道
implementation 'com.tencent.xinge:xinge:4.0.5-release'
//implementation'com.tencent.xinge:xinge:4.3.1-beta'
//jg包
implementation'com.tencent.jg:jg:1.1'
//wup包
implementation 'com.tencent.wup:wup:1.0.0.E-release'
//mid包,minSdkVersion 14
implementation 'com.tencent.mid:mid:4.0.7-Release'
注意:
如果在添加以上 abiFilter 配置之后 Android Studio 出现以下提示:
NDK integration is deprecated in the current plugin. Consider trying the new experimental plugin.
则在 Project 根目录的 gradle.properties 文件中添加:
android.useDeprecatedNdk=true
在application类中
oncreate方法里
XGPushConfig.enableDebug(this,true);
XGPushConfig.enableOtherPush(getApplicationContext(), true);
XGPushConfig.setHuaweiDebug(true);
XGPushConfig.setMiPushAppId(getApplicationContext(), "APPID");
XGPushConfig.setMiPushAppKey(getApplicationContext(), "APPKEY");
XGPushConfig.setMzPushAppId(this, "APPID");
XGPushConfig.setMzPushAppKey(this, "APPKEY");
//token注册
XGPushManager.registerPush(this, new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
//token在设备卸载重装的时候有可能会变
Log.d("TPush", "注册成功,设备token为:" + data);
}
@Override
public void onFail(Object data, int errCode, String msg) {
Log.d("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
}
});
//设置账号
XGPushManager.bindAccount(getApplicationContext(), "XINGE");
//设置标签
XGPushManager.setTag(this,"XINGE");
不要忘了在清单文件里注册
如需监听消息请参考XGBaseReceiver接口或者是 demo 的 MessageReceiver 类。自行继承XGBaseReceiver并且在清单文件中配置如下内容:复制完这些可能会报错,这是因为我们少复制了一些class文件,
<receiver android:name="完整的类名.MessageReceiver"//改成自己的路径
android:exported="true" >
<intent-filter>
<!-- 接收消息透传 -->
<action android:name="com.tencent.android.tpush.action.PUSH_MESSAGE" />
<!-- 监听注册、反注册、设置/删除标签、通知被点击等处理结果 -->
<action android:name="com.tencent.android.tpush.action.FEEDBACK" />
</intent-filter>
</receiver>
打开下载的SDK压缩包
点击进入文件夹


还有common里的DBOpenHelper类和NotificationService类。
每个类都要打开看一下,将包重新倒一下
这样配置就完成了。能够通过信鸽推送了!!!
要是还有什么不懂的,可以自己去官网看开发文档