
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
cordova-plugin-mixpush
Advanced tools
Cordova 推送,支持设置角标,事件回调。 此项目代码设计以混合推送为基础,兼容多种推送引擎。
注意:此插件的依赖的组件来自mvn仓库,所以需要翻墙。
JAVA SDK 需要1.7版本低于1.7会编译switch语法错误(环境变量是JDK1.7不一定build时候是1.7请查看build.gradle文件下的sourceCompatibility targetCompatibility)。
此项目运用于我公司商业项目上,功能都没问题,我不太会写文档,如有技术问题可邮件询问:qq3451927565
如何使用?
cordova plugin add cordova-plugin-mixpush --variable ANDROID_PACKAGE_NAME=你的安卓项目包名 --variable MI_PUSH_APP_IOS_ID=你IOS推送id --variable MI_PUSH_APP_IOS_KEY=你的IOS推送Key
code:
//此代码为最简单用法,详细使用API,请参考www目录下的MixPushPlugin.js 注释
document.addEventListener('deviceready',push , false);
function push(){
var deviceBrand="xiaoMi";//目前只支持小米引擎
window.plugins.MixPushPlugin.setPushEngine([deviceBrand]);
var miId = '2882303******08931'; //android id
var miKey = '57117***2931'; //android key
//开始启动注册小米推送
window.plugins.MixPushPlugin.registerPush([miId, miKey]);
//registerPush事件
document.addEventListener("MixPushPlugin.onRegisterPush", function onCallBack(data) {
if (data&&data.code == 200 ) {
console.log('注册成功:' + data.regId);
setAlias("qq112");//注册成功就设置Alias
}else{
console.log('注册失败:');
}
}, false);
//设置Alias
function setAlias(alias) {
window.plugins.MixPushPlugin.setAlias([alias]);
//onSetAliasPush事件
document.addEventListener("MixPushPlugin.onSetAliasPush", function onCallBack(data) {
if (data) {
data.code == 200 ? "" : setAlias(data.alias);
console.log("MixPushPlugin.onSetAliasPush" + data.alias);
}
}, false);
}
//来消息后的事件监听
document.addEventListener("MixPushPlugin.onNotificationArrived",function onCallBack(data) {
if (data && data.title) {
window.plugins.MixPushPlugin.badgerApplyCount([20]);//来消息后把APP图标上的角标数字改成20
console.log('来消息了:' + data.title);
alert(data.title);
}
}, false);
//点消息后的事件监听
document.addEventListener("MixPushPlugin.onNotificationClicked", function onCallBack(data) {
if (data && data.title) {
window.plugins.MixPushPlugin.badgerApplyCount([0]);//点消息后清空数字
console.log('点消息了:' + data.title);
alert(data.title);
}
}, false);
}
配置MiSDKRun :https://dev.mi.com/doc/?p=2995#d5e70 (如果是测试证书测试环境请配置为Debug)
XCODE推送开关:Xcode中的Capabilities中的Push Notifications打开
当APP被用户按了home键处在后台时,JS可能是停止执行的,那来了消息如何设置角标,只需要让后端大兄弟在推送时角标数即可
android
new Message.Builder()
.extra("unrecv", "" + unrecv) //unrecv int类型的值
ios
new Message.IOSBuilder()
.badge(unrecv)//unrecv int类型的值
FAQs
cordova mipush xiaomi
The npm package cordova-plugin-mixpush receives a total of 1 weekly downloads. As such, cordova-plugin-mixpush popularity was classified as not popular.
We found that cordova-plugin-mixpush demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.