簡介(下載地址)
Ba-KeepAlive-U 是一款android原生保活插件,UTS版本(同時支持uniapp和uniappx),支持市面上大部分機型,Android4.4到Android14(**注意:**不保證支持所有機型和場景,建議先試用)。
可解決定位、推送、websocket、定時任務、藍牙、聊天等保活問題。
- 采用多種主流保活技術
截圖展示
可關注博客,實時更新最新插件:
uniapp 常用原生插件大全
安卓保活(采用多種主流技術) Ba-KeepAlive
安卓保活套裝(通用、常駐通知、電池優化、自啟管理、后臺運行等) Ba-KeepAlive-Suit(文檔)
使用方法
在 script
中引入組件
import * as keepAlive from "@/uni_modules/Ba-KeepAlive-U";
在 script
中調用
import * as keepAlive from "@/uni_modules/Ba-KeepAlive-U";export default {data() {return {}},methods: {register() { //注冊let options = {channelId: "Ba-KeepAlive-U",channelName: "Ba-KeepAlive-U",title: "Ba-KeepAlive-U",content: "Ba-KeepAlive-U is running",success: (res : keepAlive.ApiResult) => {console.log(res)}} as keepAlive.ApiOptions;keepAlive.register(options);},unregister() { //注銷let res = keepAlive.unregister();console.log(res)},isRunning() { //是否正在運行let res = keepAlive.isRunning();console.log(res)},
方法清單
名稱 | 說明 |
---|---|
register | 注冊保活服務,建議在Application里初始化 |
isRunning | 查看保活服務是否運行 |
unregister | 注銷保活服務,并不會立馬停止,而是在1s之后停止,非必須調用,比如可以在app完全退出的時候可以調用,根據你的需求調用 |
register 方法參數
注冊保活服務
屬性名 | 類型 | 必填 | 默認值 | 說明 |
---|---|---|---|---|
channelId | String | 建議 | ‘Ba-KeepAlive-U’ | 渠道Id,建議用戶修改,非必傳 |
channelName | String | 建議 | ‘Ba-KeepAlive-U’ | 渠道名,用于設置里通知渠道展示,建議用戶修改,非必傳 |
title | String | 建議 | ‘Ba-KeepAlive-U’ | 通知欄標題,建議用戶修改,非必傳 |
content | String | 建議 | ‘Ba-KeepAlive-U is running’ | 通知欄內容,建議用戶修改,非必傳 |
UTS基礎文檔
UTS 語法
UTS API插件
UTS 組件插件
Hello UTS