Post

Replies

Boosts

Views

Activity

BGProcessingTaskRequest execute randomly.
I am using BGProcessingTaskRequest to fetch a API make my app up to date. Sometimes this background task execute with 10 minutes some times it take more than 10 mins, Some other times its never execute. But in my case im provide just 1 minute to BGProcessingTaskRequest.earliestBeginDate variable. And i will share my implementation here, My codes are, Called the register function before app launching. let taskId = "_________" func registerBackgroundTaks() { BGTaskScheduler.shared.register(forTaskWithIdentifier: taskId, using: nil) { task in self.handleBackgroundProcessRequest(task: task as! BGProcessingTask) } print("Receiver called") } Called the scheduleBackgroundPrecessingTask function when application enter in background mode. func scheduleBackgroundPrecessingTask() { let request = BGProcessingTaskRequest(identifier: taskId) request.requiresNetworkConnectivity = false // Need to true if your task need to network process. Defaults to false. request.requiresExternalPower = false request.earliestBeginDate = Date(timeIntervalSinceNow: 1 * 60) // Featch Image Count after 1 minute. do { try BGTaskScheduler.shared.submit(request) print("Process notification triggered") } catch { print("Could not schedule background process: \(error)") } } Could anyone share any concerns to my problem? or kindly clarify me why BGProcessingTaskRequest takes time randomly?
4
0
332
Oct ’24