backgroundTask
1.0.0
这是用目标C http://hayageek.com/ios-long-rnunn-running-background-task/ infinite Task Infinite Task基于播放空白的音频文件,这是Infinite运行背景任务的示例的更新Swift版本。我的版本被简化为Minumum,可以在后台永远运行任务。我还提供了一个空白的WAV文件,该文件将永远播放,直到您停止任务为止。 *注意:24小时内电池消耗为10%。
#youtube教程和概述https://www.youtube.com/watch?v=j7b35lfcmqm
将手动文件BackgroundTask.swift到您的项目中。
#warning如果您打算将应用程序推向应用商店,请不要使用我的实现。苹果将100%拒绝这种行为。该项目是为了研究目的或个人用途而设计的。
var backgroundTask = BackgroundTask ( )
//Start playing blank audio file.
//You can run NSTimer() or whatever you need and it will continue executing in the background.
backgroundTask . startBackgroundTask ( )
//Stop the task when you don't need it
backgroundTask . stopBackgroundTask ( )