0

我在使用 CloudKit 的应用程序中工作。我正在实现一种将增量从 CloudKit 获取到我的应用程序的方法(我正在使用公共数据库)。我从 fetchNotificationChangesCompletionBlock 块收到响应,但我没有从 notificationChangedBlock 收到响应。

这是我的代码:

-(void)checkForNewData
{
    CKServerChangeToken *token = [[cloudKitToken helper] getCloudKitToken];
    CKFetchNotificationChangesOperation *op = [[CKFetchNotificationChangesOperation alloc]
                                               initWithPreviousServerChangeToken:token];
    NSMutableArray *noteIds = [[NSMutableArray alloc] init];

    op.notificationChangedBlock = ^(CKNotification *note)
    {
        CKNotificationID *noteId = note.notificationID;
        [noteIds addObject:noteId];

        if([note isKindOfClass:[CKQueryNotification class]]) {
            CKQueryNotification *qNote = (CKQueryNotification *)note;
            CKRecordID *changedRecordID = qNote.recordID;

            NSLog(@"I got CKQueryNotification");

        }

    };

    op.fetchNotificationChangesCompletionBlock = ^(CKServerChangeToken *token, NSError *error) {

        NSLog(@"error %@", error.localizedDescription);
    };

    [[CKContainer defaultContainer] addOperation:op];
}

你们中的任何人都知道我做错了什么或我的代码有什么问题吗?

我会非常感谢你的帮助。

4

0 回答 0