当前位置:   article > 正文

uniapp:APP开发,后台保活_uniapp 保活

uniapp 保活

前言:

  1. 在ios中,软件切换至后台、手机息屏,过了十来秒软件就会被系统挂起,APP内的任务就不能继续执行;
  2. 在android中,默认情况下,软件在后台运行的时候,触发某些特定条件的情况下,会被杀掉进程。

解决方案:

以下方案均测试息屏后台运行两小时

一、后台运行音频(无声音频)(一般)

manifest.json配置:APP常用其他设置—ios设置-后台运行能力,开启audio

代码:

// 开启后台音乐模式
import icon from '@/static/appIcons/20x20.png';
const playTimes = ref(0);
const createAudio = () => {
   
  const bgAudioManager = uni.getBackgroundAudioManager();
  bgAudioManager.title = '正在运行';
  bgAudioManager.singer = '小熊管家';
  bgAudioManager.coverImgUrl = icon;
  bgAudioManager.src =
    'https://******/keepAppLife.mp3';
  let t: any = null;
  const rePlay = () => {
   
    if (t) {
   
      return;
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/587244
推荐阅读
相关标签
  

闽ICP备14008679号