uni-app极光推送:https://blog.csdn.net/dashenid/article/details/103437459
由于html5+没有提供绑定、解绑别名的方法,
用native.js去实现,点用原生的个推方法
igexinTool.js
function igexinTool() {
var isAndorid, PushManager, context, Instance, GeTuiSdk;
if(plus.os.name == 'Android') {
isAndorid = true;
} else {
isAndorid = false;
}
if(isAndorid) {
PushManager = plus.android.importClass("com.igexin.sdk.PushManager");
context = plus.android.runtimeMainActivity().getContext();
Instance = PushManager.getInstance();
} else {
GeTuiSdk = plus.ios.importClass("GeTuiSdk");
}
this.bindAlias = function(alias) {
if(isAndorid) {
Instance.bindAlias(context, alias);
} else {
GeTuiSdk.bindAliasandSequenceNum(alias, alias);
}
}
this.unbindAlias = function(alias) {
if(isAndorid) {
Instance.unBindAlias(context, alias, true);
} else {
GeTuiSdk.unbindAliasandSequenceNumandIsSelf(alias, alias, true);
}
}
this.getVersion = function() {
if(isAndorid) {
return Instance.getVersion(context);
} else {
return GeTuiSdk.version;
}
}
//开启推送
this.turnOnPush = function() {
if(isAndorid) {
Instance.turnOnPush(context);
} else {
GeTuiSdk.setPushModeForOff(false);
}
}
//关闭推送
this.turnOffPush = function() {
if(isAndorid) {
Instance.turnOffPush(context);
} else {
GeTuiSdk.setPushModeForOff(true);
}
}
}
使用:
<script src="lib/igexinTool.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
mui.plusReady(function() {
var tool = new igexinTool();
tool.bindAlias("ykj");
});
</script>