直接到插件市场购买点击:
概述
支持安卓service服务持续运行,避免系统干掉应用进程
如何调用插件
const keepLiveService = uni.requireNativePlugin('yuange-YGKeepLiveServiceModule');检查通知权限是否开启
keepLiveService.isNotificationEnabled({
}, result => {
modal.toast({
message: JSON.stringify(result) ,
duration: 1.5
});
});唤起通知设置
keepLiveService.invokeNotification({
}, result => {
modal.toast({
message: JSON.stringify(result) ,
duration: 1.5
});
});启动服务
keepLiveService.start({
title: "我正在每2秒刷新一次日志",
big_title : "带定时器的演示demo",
content: "请不要关闭该服务,否则我无法刷新日志..." ,
"delaysec" : 2000,
"isIgnoringBattery" : false,//不开启电池优化
}, result => {
console.log(result)
});关闭服务
keepLiveService.stop({
}, result => {
modal.toast({
message: "closed",
duration: 1.5
});
});











评论