ndk {
//根据需要 自行选择添加的对应cpu类型的.so库。
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
}
manifestPlaceholders = [
XG_ACCESS_ID : XG_ACCESS_ID,
XG_ACCESS_KEY: XG_ACCESS_KEY,
]
//信鸽3.2.4 beta版本
compile 'com.tencent.xinge:xinge:3.2.4-beta'
//wup包
compile 'com.tencent.wup:wup:1.0.0.E-release'
//mid包
compile 'com.tencent.mid:mid:4.0.6-release'
则在 Project 根目录的 gradle.properties 文件中添加:
android.useDeprecatedNdk=true
自行继承XGBaseReceiver并且在配置文件中配置如下内容:
private void initXGPush() {
XGPushConfig.enableOtherPush(getApplicationContext(), true);
XGPushConfig.enableDebug(this, true);
XGPushManager.registerPush(getApplicationContext(),
new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
Log.d(TAG, "+++ register push sucess. token:" + data + "; flag:" + flag);
}
@Override
public void onFail(Object data, int errCode, String msg) {
Log.w(TAG, "+++ register push fail. token:" + data + ", errCode:" + errCode + ",msg:" + msg);
}
});
}
public class XGClickDispatchActivity extends Activity {
private static final String TAG = XGClickDispatchActivity.class.getSimpleName();
private static final String XG_PUSH = "xgscheme://click/dispatch?url=";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate : xg push notification clicked");
Uri uri = getIntent().getData();
if (uri != null) {
String url = uri.toString().replace(XG_PUSH,"");
Log.d(TAG, "uri = " + uri.toString());
handleUrl(url);
} else {
Log.d(TAG, "uri = null");
handleUrl("");
}
finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.d(TAG, "onDestroy");
}
private void handleUrl(String url) {
Log.d(TAG, "handleUrl = " + url);
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(MainActivity.EXTRA_URL, url);
intent.putExtra(MainActivity.EXTRA_CLEAR_FRAGMENT, false);
startActivity(intent);
}
}
应用:默认会打开应用
应用内界面:配置activity全路径
URL:配置https://www.baidu.com【点击打开外部浏览器,并加载url】
客户端自定义:
如果只打开界面XGClickDispatchActivity,配置xgscheme://click/dispatch即可
如果需要打开多个不同的界面,可以在界面配置里定义不同的xgscheme、host、path,组成界面uri,然后在信鸽推送配置进行测试
我只定义了1个点击入口界面,在入口内根据参数 做分发,打开不同的界面