首页 好物正文

Uniapp插件安卓Service服务保活插件、避免系统干掉进程

yuange 好物 2022-09-11 3652 0 uniapp插件

直接到插件市场购买点击:image.png

84034ff0-2ecb-11ed-a8a1-d9dbc558f9e2_1.jpeg

概述

  • 支持安卓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
                    });
                });


评论

在线客服-可直接交谈

您好!有什么需要可以为您服务吗?