更新记录
1.0.0(2025-03-05)
平台兼容性
App |
快应用 |
微信小程序 |
支付宝小程序 |
百度小程序 |
字节小程序 |
QQ小程序 |
HBuilderX 4.45,Android:5.0,iOS:不支持,HarmonyNext:不支持 |
× |
× |
× |
× |
× |
× |
钉钉小程序 |
快手小程序 |
飞书小程序 |
京东小程序 |
鸿蒙元服务 |
× |
× |
× |
× |
× |
H5-Safari |
Android Browser |
微信浏览器(Android) |
QQ浏览器(Android) |
Chrome |
IE |
Edge |
Firefox |
PC-Safari |
× |
× |
× |
× |
× |
× |
× |
× |
× |
温馨提示 如何调用插件
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);
}
});