admin 管理员组

文章数量: 1184232

前言:

  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;
    }
    t = setTimeout

本文标签: 后台 uniapp App