我使用CloudKit在app中工作。我实现了一种从CloudKit到我的app获取增量的方法(我使用公共数据库)。我收到了来自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];
}
你们中的任何人都知道我的错误或我的代码有什么问题吗?
我非常感谢你的帮助。