gpt4 book ai didi

ios - BGTaskScheduler 提交调用失败,BGTaskSchedulerErrorDomain 代码为 : 1

转载 作者:行者123 更新时间:2023-11-28 20:50:45 57 4
gpt4 key购买 nike

BGTaskScheduler 因“BGTaskSchedulerErrorDomain”而失败 - 代码:iOS 13.0 上的 1

我已经尝试过 Apple 提供的示例程序 ColorFeed,它面临同样的问题

let request = BGProcessingTaskRequest(identifier: "com.example.apple-samplecode.ColorFeed.db_cleaning")
request.requiresNetworkConnectivity = false
request.requiresExternalPower = true

do
{
try BGTaskScheduler.shared.submit(request)
} catch {
print("Could not schedule database cleaning: \(error)")
}

上面的代码在 applicationDidEnterBackground 中被调用

早些时候任务在 didFinishLaunchingWithOptions 中注册 ...

 BGTaskScheduler.shared.register(forTaskWithIdentifier: "com.example.apple-samplecode.ColorFeed.db_cleaning", using: nil) { task in

// Downcast the parameter to a processing task as this identifier is used for a processing request.
self.handleDatabaseCleaning(task: task as! BGProcessingTask)

}

最佳答案

代码1表示BGTaskScheduler.Error.unavailable

根据文档:

This error usually occurs for one of three reasons:

  • The user has disabled background refresh in settings.
  • The app is running on Simulator which doesn’t support background processing.
  • The extension either hasn’t set RequestsOpenAccess to YES in The Info.plist File, or the user hasn’t granted open access.

您是在真实设备上运行吗?该设备是否启用了后台刷新?

关于ios - BGTaskScheduler 提交调用失败,BGTaskSchedulerErrorDomain 代码为 : 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58680588/

57 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com