iOS 9 Cloudkit: Query Does Not Return Anything While Connected to Cellular Network

iOS 9 CloudKit: query does not return anything while connected to cellular network

Open the settings app, find your app, enable 'use mobile data'

Update: As discussed below
Adding the following line of code solved the problem:

queryOperation.qualityOfService = .UserInteractive

The reason why this works must be a timing / load issue. My initial guess would be that this is caused by this line:

queryOperation.queuePriority = .VeryHigh

The documentations states for the .queuePriority this:
You should use priority values only as needed to classify the relative priority of non-dependent operations.

The documentation states for the .qualityOfService this:
The default value of this property is NSOperationQualityOfServiceBackground and you should leave that value in place whenever possible.

So please try removing both the .queuePriority and .qualityOfService and see if it's working.

Update 2: Apparently this is a CloudKit bug. More people have the same issue. Please report it at https://bugreport.apple.com

Cloudkit: CKDatabaseOperation not working on cellular

Someone in the Developer Forums of Apple found a solution:
https://forums.developer.apple.com/thread/20047

the magic happens when setting qualityOfService = .UserInitiated

Example:

let publicDB = CKContainer.defaultContainer().publicCloudDatabase    
let operation = CKModifyRecordsOperation(recordsToSave: [aRecord], recordIDsToDelete: nil)

operation.allowsCellularAccess = true
operation.qualityOfService = .UserInitiated // <----- THATS THE CELLULAR FIX

operation.perRecordProgressBlock = {(record, progress) in
print("Progress: \(Int(progress*100.0))%")
}
operation.perRecordCompletionBlock = {(record, error) in
print("Upload complete") //Add awesome error handling here
}
publicDB.addOperation(operation)

iOS: CloudKit perform(query: ) does nothing - closure not executed

In the completion handler shown here, if there's no error and no results are found, execution will fall through and quietly exit. So, there are two possible conditions happening here: the query isn't running or the query isn't finding any results. I'd perform the following investigative steps, in order:

  1. Check your .entitlements file for the key com.apple.dev.icloud-container-environment. If this key isn't present, then builds from xcode will utilize the development environment. If this key is set, then builds from xcode will access the environment pointed to by this key. (Users that installed this app from Testflight or the app store will always use the production environment).
  2. Open the cloudkit dashboard in the web browser and validate that the records you expect are indeed present in the environment indicated by step 1 and the container you expect. If the records aren't there, then you've found your problem.
  3. If the records appear as expected in the dashboard, then place the breakpoint on the .perform line. If the query is not being called when you expected, then you need to look earlier in the call stack... who was expected to call this function?
  4. If the .perform is being called as expected, then add an else to the if let record statement. Put a breakpoint in the else block. If that fires, then the query ran but found no records.
  5. If, after the above steps, you find that the completion handler absolutely isn't executed, this suggests a malformed query. Try running the query by hand using the cloudkit dashboard and observing the results.

Very weird issues with xcode 7 and cloudkit

Apple has changed the behavior of the qualityOfService setting and the way data is fetched. In my opinion this is a CloudKit bug. For more information see:
iOS 9 CloudKit: query does not return anything while connected to cellular network

Please also make a bug report of this at http://bugreport.apple.com

CloudKit method call hung up

Adding the following line of code will probably solve your problem:

queryOperation.qualityOfService = .UserInteractive

In iOS 9 Apple changed the behavior of that setting. Especially when using cellular data you could get the behaviour you described.

The documentation states for the .qualityOfService this:
The default value of this property is NSOperationQualityOfServiceBackground and you should leave that value in place whenever possible.

In my opinion this is more a CloudKit bug than a changed feature. More people have the same issue. I did already report it at https://bugreport.apple.com

CKQueryOperation not returning error when device offline

As per usual I post a bounty and find the answer within the next hour or 2. Not sure how I missed this originally but it contained the answer I was looking for.

So by adding this line

queryOperation.qualityOfService = .UserInitiated

something behind the scenes changes and we have some nice action within

queryOperation.queryCompletionBlock = { (cursor: CKQueryCursor?, error: NSError?) in
// We get an error message... Finally !!
print(error)
}

Couldn't find anything in the Apple Docs to hint at this either.

Saving CloudKit Record Not Authenticated (9/1002) This request requires an authenticated account

I got the same problem, which I was able to resolve by logging in to my iCloud account in the simulator (Settings > iCloud).

As of the latest Xcode, you can log in to your iCloud account in the simulator, and everything should work.

If you are having trouble logging in, try to go to iCloud.com on a desktop and log in there first. Once that is set up properly, then try in the simulator.

CKError localizedDescription

Looks like there is another error in the errorUserInfo[NSUnderlyingError]. Try getting the localizedDescription from that error.

So, that would be:

((error as? CKError)?.errorUserInfo[NSUnderlyingErrorKey] as? NSError)?.localizedDescription


Related Topics



Leave a reply



Submit