Swift:已忽略启动新后台任务的请求,因为RunningBoard已启动过期计时器

Swift:已忽略启动新后台任务的请求,因为RunningBoard已启动过期计时器,swift,Swift,我有一系列由静默推送通知触发的任务。收到推送通知后,它会在后台唤醒iOS并执行以下任务: 打开包含WKWebview的WebViewController 转到网页,单击javascript注入自动执行的一些按钮 完成后,将解除WebViewController 我已经添加了选定的BackgroundTasks处理程序来管理它,但控制台中充斥着以下警告 [ProcessSuspension] 0x280486080 - WKProcessAssertionBackgroundTaskManager

我有一系列由静默推送通知触发的任务。收到推送通知后,它会在后台唤醒iOS并执行以下任务:

  • 打开包含WKWebview的WebViewController
  • 转到网页,单击javascript注入自动执行的一些按钮
  • 完成后,将解除WebViewController
  • 我已经添加了选定的BackgroundTasks处理程序来管理它,但控制台中充斥着以下警告

    [ProcessSuspension] 0x280486080 - WKProcessAssertionBackgroundTaskManager: Ignored request to start a new background task because RunningBoard has already started the expiration timer
    
    请注意,需要完成的任务仍然正确执行

    class WebViewController: UIViewController, WKNavigationDelegate, WKScriptMessageHandler {
    
        lazy var webView: WKWebView = {
            let v = WKWebView()
            v.translatesAutoresizingMaskIntoConstraints = false
            v.navigationDelegate = self
            return v
        }()
        
        var backgroundTask: UIBackgroundTaskIdentifier = .invalid
        
        //Remove BG task when not needed
        deinit {
            NotificationCenter.default.removeObserver(self)
            endBackgroundTask()
        }
        
        override func viewDidLoad() {
            super.viewDidLoad()
            
            //Register notification for background task
            NotificationCenter.default.addObserver(self,
                                                   selector: #selector(reinstateBackgroundTask),
                                                   name: UIApplication.didBecomeActiveNotification,
                                                   object: nil)
            registerBackgroundTask()
    
            
            //Load webview with  URL
            if let url = url {
                let request = URLRequest(url: url)
                webView.load(request)
            }
        }
        
        //MARK:- Handle BG Tasks
        
        func registerBackgroundTask() {
            backgroundTask = UIApplication.shared.beginBackgroundTask { [weak self] in
                self?.endBackgroundTask()
            }
        }
        
        func endBackgroundTask() {
            Log("Background task ended.")
            UIApplication.shared.endBackgroundTask(backgroundTask)
            backgroundTask = .invalid
        }
        
        @objc func reinstateBackgroundTask() {
            if backgroundTask == .invalid {
                registerBackgroundTask()
            }
        }
        
        func endBackgroundTaskIfNotInvalid() {
            if backgroundTask != .invalid {
                self.endBackgroundTask()
            }
        }
        
        //This is the final task that needs to be done 
        fileprivate func updateScheduler(visitedPlace: VisitedPlace) {
            if navigator == .scheduler {
                
                if let jobId = jobId {
                    let data = [
                        "status": "scheduled",
                        "completedOn": Date()
                    ] as [String : Any]
                    
                    ///Do some work here...
                        
                    //Dismiss controller after completing
                    self.dismiss(animated: true) {
                        self.endBackgroundTaskIfNotInvalid()
                    }
                }
            } else {
                self.endBackgroundTaskIfNotInvalid()
            }
        }
    }
    

    是什么触发了所有这些警告?如何使其静音?

    我正在使用相同的控制台。对我来说,结果证明是adMob造成的。

    当我运行等待测试期望值被满足的单元测试时,这种情况发生在我身上。我希望这只是一个模拟器问题,因为我在生产中没有看到它,但听起来好像不是这样。

    我通过从应用程序暂停的视图层次结构中删除AdMob横幅修复了洪水:

    self.bannerView?.removeFromSuperview()
    

    AdMob仍然很少尝试生成一条日志消息。

    您是如何解决这个问题的?我也面临着这个问题。不幸的是,没有