CloudKit fetchRecordChangesOperation gives a “AppDefaultZone does not support sync semantics”

筅森魡賤 提交于 2019-12-22 04:09:35

问题


I'm using a CKFetchRecordChangesOperation with a CKFetchRecordsChangeToken to grab changes and it is telling me that the "AppDefaultZone does not support sync semantics".

Here is the offending code:

- (void)downloadServerChangesWithCompletionBlock:(void (^)(NSError *error))completionBlock
{
    // Prepare to fetch remote changes
    CKDatabase *database = [CKContainer defaultContainer].privateCloudDatabase;
    CKRecordZoneID *zoneID = [[CKRecordZoneID alloc] initWithZoneName:CKRecordZoneDefaultName ownerName:CKOwnerDefaultName];

    // Initialize fetch record changes operation
    CKFetchRecordChangesOperation *fetchRecordChangesOperation = [[CKFetchRecordChangesOperation alloc] initWithRecordZoneID:zoneID previousServerChangeToken:[self changeToken]];
    fetchRecordChangesOperation.recordChangedBlock = ^(CKRecord *record) {
        [self performRecordChange:record];
    };
    fetchRecordChangesOperation.recordWithIDWasDeletedBlock = ^(CKRecordID *recordID){
        [self performRecordDeletion:recordID];
    };
    fetchRecordChangesOperation.fetchRecordChangesCompletionBlock = ^(CKServerChangeToken *serverChangeToken, NSData *clientChangeTokenData, NSError *error) {
        if (error) {
            completionBlock(error);
        } else {
            [self setChangeToken:serverChangeToken];
            completionBlock(nil);
        }
    };

    // Perform the operation
    [database addOperation:fetchRecordChangesOperation];
}

And here is the error it is printing out

[PBCloudKitSyncManager] Error Downloading Data:
<CKError 0x157a2500: "Server Rejected Request" (15/2027);
server message = "AppDefaultZone does not support sync semantics";
uuid = [redacted];
container ID = "[redacted]">

回答1:


I fixed the problem by switching to a custom zone. I create the zone when I initialize CloudKit and when I go to initialize the zoneID I use this:

CKRecordZoneID *zoneID = [[CKRecordZoneID alloc] initWithZoneName:@"Custom Zone Name" ownerName:userRecordName];

where userRecordName is the record name for the CKRecord I get for the user when I call this method in the Cloudkit initialization:

[CKContainer defaultContainer] fetchUserRecordIDWithCompletionHandler:^(CKRecordID *recordID, NSError *error) {
     if (recordID) {
         // Save the user record id
         [self saveUserRecordName:recordID.recordName];

          /...

      }
}];


来源:https://stackoverflow.com/questions/25777023/cloudkit-fetchrecordchangesoperation-gives-a-appdefaultzone-does-not-support-sy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!