我想做一个可以在后台快速继续的下载,但是当我切换到后台时,蓝牙文件传输停止

问题描述

func applicationDidEnterBackground(_ application: UIApplication) {
    print("Entered Background")

    bgTask = application.beginBackgroundTask(expirationHandler: {
        self.bgTask = uibackgroundtaskIdentifier.invalid
        self.cb_central = CBCentralManager()
        self.cb_central.delegate = self
        
        self.centralManagerDidUpdateState(self.cb_central)
        Definations.isFileTransferInProgress = true
        VoiceRecordMainVC().downloadFile()
    })
   
}

func applicationWillEnterForeground(_ application: UIApplication) {
    UIApplication.shared.endBackgroundTask(bgTask)
}

我有这样的代码,当它进入后台时,我告诉下载继续,实际上我告诉它再次开始下载。您认为这样做可行吗,我该怎么做,谢谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)