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 ( )