Sometimes subscription to CloudKit does not work

If I try to sign up for CloudKit with this code:

NSPredicate *truePredicate = [NSPredicate predicateWithValue:YES]; CKSubscription *itemSubscription = [[CKSubscription alloc] initWithRecordType:RecordType predicate:truePredicate options:CKSubscriptionOptionsFiresOnRecordCreation | CKSubscriptionOptionsFiresOnRecordUpdate | CKSubscriptionOptionsFiresOnRecordDeletion]; CKNotificationInfo *notification = [[CKNotificationInfo alloc] init]; notification.alertBody = @"Item Added/Updated/Deleted!"; itemSubscription.notificationInfo = notification; [self.publicDatabase saveSubscription:itemSubscription completionHandler:^(CKSubscription *subscription, NSError *error) { if (error) { // In your app, handle this error appropriately. NSLog(@"An error occured in %@: %@", NSStringFromSelector(_cmd), error); } else { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:subscription.subscriptionID forKey:kSubscriptionID]; [defaults synchronize]; } }]; 

I sometimes get this error:

CKError 0x17558460: "Rejected server request" (15/2000); server message = "Internal server error"; uuid = B89DE7A4-9D22-42BC-9CD4-4330F3FE04EF; container ID = "iCloud.com.app.testApp"

or

CKError 0x14fb3510: "Service unavailable" (6/2022); server message = "Could not install schema, CAS failed"; uuid = F562D1AD-B40E-4842-A5EA-2A5F800C18F2; container ID = "iCloud.com.app.testApp"

Does anyone know how to fix this? Can I do something with my code? Is this an Apple problem and I can’t do anything? Thanks.

+7
ios ios8 cloudkit cksubscription
source share
3 answers

I recently got a similar error and was able to solve it by switching CloudKit to the project capabilities. Once I reset got CloudKit permission, everything seemed to work fine.

+3
source share

I had the same problem. I ended up changing containers completely (project goal goo -> Capabilities -> specify custom containers -> enter a new container identifier). It worked great after.

+1
source share

I had an exact error: "Request for server rejection" (15/2000); server message = "Internal server error" as a result of CKModifySubscriptionsOperation.

The strange thing that tested the iPad subscription was OK. but the subscription from the iPhone did not work.

Fixed by changing the NSPredicate format:

1- old format (does not work)

1-1

let predicate = NSPredicate (format: "rate> = 0")

1-2

let x = 0 like! NSNumber

let predicate = NSPredicate (format: "rate> =", x)

2- New predicate format (fixed problem):

let predicate = NSPredicate (format: "rate> =", NSNumber (integerLiteral: 0))

+1
source share

All Articles