根据这篇个推的别名设置文章做了对应的小米推送的版本,
MIPushTool.js
function MIPushTool(){
var isAndorid, PushManager, context, MiPushSDK;
if(plus.os.name == 'Android') {
isAndorid = true;
} else {
isAndorid = false;
}
if(isAndorid) {
PushManager = plus.android.importClass("com.xiaomi.mipush.sdk.MiPushClient");
context = plus.android.runtimeMainActivity().getContext();
} else {
MiPushSDK = plus.ios.importClass("MiPushSDK");
}
this.bindAlias = function(alias) {
if(isAndorid) {
PushManager.setAlias(context, alias,'');
} else {
MiPushSDK.setAlias(alias);
}
}
this.unbindAlias = function(alias) {
if(isAndorid) {
PushManager.unsetAlias(context, alias,'');
} else {
MiPushSDK.unsetAlias(alias);
}
}
}
//调用
mui.plusReady(function() {
var tool = new MIPushTool();
tool.bindAlias(ename);
})
0 个评论
要回复文章请先登录或注册