我试图在POST,GET等后台进行调用,以便在didReceiveRemoteNotification方法中更精确,因为它们开始作为推送通知到达.我的问题是,在我打开应用程序之前,所有Alamofire.request都不会在后台模式中调用.我现在有
我试图打开一个会话,但它不会使请求工作.
这些是我想在后台执行的(后台手机)
Alamofire.Manager(configuration: configuration).request(.GET, url, parameters: nil)
.responseJSON { (_, _, JSON, _) in
//println(JSON)
println(JSON)
REST OF THE CODE
Run Code Online (Sandbox Code Playgroud)
但是它不会起作用,即使我在这些请求下面添加代码也可以工作,但是请求的返回甚至是请求都没有.
uiapplicationdelegate swift background-task alamofire backgroundtaskidentifier
将iPad更新到iOS 13后,我在应用程序内部使用后台任务,我的应用程序发出以下消息:
无法结束BackgroundTask:不存在标识符> 13(0xd)的后台任务,或者它可能已经结束。中断UIApplicationEndBackgroundTaskError()进行调试。
我使用UIApplicationEndBackgroundTaskError()进行了调试,但是没有得到任何结果,并且我已经在iOS 12和其他以前的版本上对其进行了测试,它运行良好。
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)")
}
Run Code Online (Sandbox Code Playgroud)
上面的代码在 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)
}
Run Code Online (Sandbox Code Playgroud)