CKModifyRecordsOperation modifyRecordsCompletionBlock is not called

I use CKModifyRecordsOperation to save the recordset, and if I have an internet connection, everything works fine and the completion block is called. But when I have no connection, the completion block is not called, and I do not receive any information that my operations failed.

I use the following code in the completion block

 modifyOperations.modifyRecordsCompletionBlock = ^(NSArray *savedRecords, NSArray *deletedRecordIDs, NSError *error) { if(error){ NSLog(@"Error: %@", error.localizedDescription); } item.creatorRecordId = record.recordID; }; 

and then I perform the operation using

 [self.publicDB addOperation:modifyOperations]; 

Any ideas how I can get information if the operation is unsuccessful, for example, if there is no Internet connection?

+5
source share
1 answer

CloudKit operations by default have the qualityOfService property set to NSQualityOfServiceUtility .

Operations that use NSQualityOfServiceUtility or NSQualityOfServiceBackground can be marked as using discretionary network requests . The system can store discretionary network requests if the network connection is poor, so you cannot receive a response from the server until the conditions improve and the system sends a request.

If you want your request to be sent immediately in all cases, set CKOperation.qualityOfService to NSQualityOfServiceUserInitiated or NSQualityOfServiceUserInteractive .

+6
source

Source: https://habr.com/ru/post/1237976/


All Articles