0

When app is in active mode I start fetching records:

func fetchRecords() async throws -> -> [CKRecord] {
    let container = CKContainer(identifier: "id")
    let privateDatabase = container.privateCloudDatabase
    let zone = CKRecordZone(zoneName: "zonename")
    let query = CKQuery(recordType: "Person", predicate: NSPredicate(value: true))
    let result = try await privateDatabase.records(matching: query, inZoneWith: zone.zoneID, desiredKeys: nil)
    return result.matchResults.compactMap { try? $1.get() }
}

But while fetching is in progress app goes to inactive state and it stops fetching. Is there a way to finish it in inactive mode?

My current solution is to display Text("Tap to continue fetching") and when user wake it manually again it moves forward. It is not best solution and convenient. But if there is no other way I will have to deal with it.

Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358

0 Answers0