更新记录
1.0.0(2025-03-05)
平台兼容性
uni-app
Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
√ |
√ |
- |
- |
- |
- |
5.0 |
× |
× |
微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x
Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
- |
- |
5.0 |
× |
× |
- |
温馨提示 如何调用插件
import {
requestIgnoreBattery,
goIgnoreBattery,
isIgnoringBattery,
onAutoStart,
onKeep,
onShowNotify,
onCancelNotify,
isNotificationEnabled,
invokeNotification
} from "@/uni_modules/yuange-keepalive"
检查是否开启通知栏权限
isNotificationEnabled({
success(res) {
console.log(res);
},
fail(err) {
console.log(err);
}
});
开启通知栏权限(用于常驻通知保活执行条件)
invokeNotification({
success(res) {
console.log(res);
},
fail(err) {
console.log(err);
}
});
常驻通知保活(通知图标修改,自己建目录对应如下:uni_modules/yuange-keepalive/utssdk/app-android/res/mipmap-xxhdpi/ic_launcher.png)
let p = {
// channelId: "yuange-KeepAlive",
// channelName: "yuange-KeepAlive",
// ID: 10,
title: "测试",
content: "常驻通知描述",
};
onShowNotify(JSON.stringify(p), {
success(res) {
console.log(res);
},
fail(err) {
console.log(err);
}
});
取消常驻通知保活
let p = {
channelId: "yuange-KeepAlive",
channelName: "yuange-KeepAlive",
ID: 10,
title: "测试",
content: "常驻通知描述",
};
onCancelNotify(JSON.stringify(p), {
success(res) {
console.log(res);
},
fail(err) {
console.log(err);
}
});
开启通用保活
let p = {
channelId: "yuange-KeepAlive",
channelName: "yuange-KeepAlive",
title: "测试",
content: "常驻通知描述",
};
onKeep(JSON.stringify(p), {
success(res) {
console.log(res);
},
fail(err) {
console.log(err);
}
});
去设置自启动、后台运行
onAutoStart({
success(res) {
console.log(res);
},
fail(err) {
console.log(err);
}
});
申请加入电池优化白名单
requestIgnoreBattery({
success(res) {
console.log(res);
},
fail(err) {
console.log(err);
}
});
跳转到电池优化设置页
goIgnoreBattery({
success(res) {
console.log(res);
},
fail(err) {
console.log(err);
}
});
是否加入电池优化白名单
isIgnoringBattery({
success(res) {
console.log(res);
},
fail(err) {
console.log(err);
}
});