I'm struggling to share a record. I'm getting and error that my zone is not shared. No idea how to share the zone either than doing the process below. Error is here...
I created a custom zone using the following...
I then saved a Record using this zone. I've confirmed that the record exists, in that zone, in my private Database on the dashboard.
I then initiate the share (using the UICloudSharingController) as follows...
Finally my CloudKitManager shareRootRecord looks like this...
Line 19 is the output of this error. I'm confused what to do here. I though the act of sharing out this record in this custom zone should make that zone shared? I'm not sure what else I'm supposed to do on the custom zone? I can't find anything in the Documentation or even online about how to share the custom zone either than just sharing the record.
Very much appreciate any suggestions here.
Code Block <CKError 0x28107db30: "Partial Failure" (2/1011); "Failed to modify some records"; uuid = 025CA822-96A0-46FB-B2EE-7CB06D1ECCF8; container ID = "iCloud.[MY DOMAIN]"; partial errors: { Share-182263AB-B5AC-466D-A5D0-34F63D37ADDA:(GameZone:defaultOwner) = <CKError 0x281077bd0: "Invalid Arguments" (12/2006); server message = "Only shared zones can be accessed in the shared DB"; uuid = 025CA822-96A0-46FB-B2EE-7CB06D1ECCF8>
I created a custom zone using the following...
Code Block CKContainer *container = [CKContainer defaultContainer]; CKDatabase *db = container.privateCloudDatabase; CKRecordZone *tempZone = [[CKRecordZone alloc] initWithZoneName:@"GameZone"]; [db saveRecordZone:tempZone completionHandler:^(CKRecordZone * _Nullable zone, NSError * _Nullable error) { if (error != nil) { NSLog(@"%@", error); } else { NSLog(@"Successfully created GameZone --- %@", zone); } }];
I then saved a Record using this zone. I've confirmed that the record exists, in that zone, in my private Database on the dashboard.
I then initiate the share (using the UICloudSharingController) as follows...
Code Block Game *theGame = [self.common.coreManager getGameByObjectID:self.gameObjectID]; CKRecord *record = [[CKRecord alloc] initWithRecordType:@"Game" recordID:theGame.ckID]; UICloudSharingController *sharingController = [[UICloudSharingController alloc] initWithPreparationHandler:^(UICloudSharingController * _Nonnull controller, void (^ _Nonnull preparationCompletionHandler)(CKShare * _Nullable, CKContainer * _Nullable, NSError * _Nullable)) { [CloudKitManager shareRootRecord:record name:theGame.name completion:preparationCompletionHandler]; }]; [sharingController setModalPresentationStyle:UIModalPresentationFullScreen]; [self presentViewController:sharingController animated:YES completion:nil];
Finally my CloudKitManager shareRootRecord looks like this...
Code Block + (void)shareRootRecord:(CKRecord *)rootRecord name:(NSString *)name completion:(void (^)(CKShare * _Nullable share, CKContainer * _Nullable container, NSError * _Nullable error))completion { CKShare *shareRecord = [[CKShare alloc] initWithRootRecord:rootRecord]; shareRecord[CKShareTitleKey] = name; shareRecord[CKShareTypeKey] = @"com.lmw.YouDJ"; [shareRecord setPublicPermission:CKShareParticipantPermissionReadOnly]; NSArray *recordsToSave = @[rootRecord, shareRecord]; CKContainer *container = [CKContainer defaultContainer]; CKDatabase *privateDatabase = [container sharedCloudDatabase]; CKModifyRecordsOperation *operation = [[CKModifyRecordsOperation alloc] initWithRecordsToSave:recordsToSave recordIDsToDelete:@[]]; [operation setModifyRecordsCompletionBlock:^(NSArray<CKRecord *> * _Nullable savedRecords, NSArray<CKRecordID *> * _Nullable deletedRecordIDs, NSError * _Nullable error) { if (error) { NSLog(@"%@", error); } completion(shareRecord, container, error); }]; [privateDatabase addOperation:operation]; }
Line 19 is the output of this error. I'm confused what to do here. I though the act of sharing out this record in this custom zone should make that zone shared? I'm not sure what else I'm supposed to do on the custom zone? I can't find anything in the Documentation or even online about how to share the custom zone either than just sharing the record.
Very much appreciate any suggestions here.