I'm working in app using CloudKit and I'm creating a subscription to CloudKit. here is my code:
CKSubscription *subscription = [[CKSubscription alloc]
initWithRecordType:recordType
predicate:predicate
options:CKSubscriptionOptionsFiresOnRecordCreation |
CKSubscriptionOptionsFiresOnRecordUpdate |
CKSubscriptionOptionsFiresOnRecordDeletion];
CKNotificationInfo *notificationInfo = [CKNotificationInfo new];
notificationInfo.shouldSendContentAvailable = YES;
subscription.notificationInfo = notificationInfo;
notificationInfo.shouldBadge = YES;
CKDatabase *publicDatabase = [container publicCloudDatabase];
[publicDatabase saveSubscription:subscription
completionHandler:^(CKSubscription *subscription, NSError *error) {
if (!error)
{
NSLog(@"subscription success!");
}
else
{
NSLog(@"subscription error%@", error.localizedDescription);
}
}];
My question to you guys. How can I query or validate the user subscription to CloudKit ?
A subscription is nothing more than a CKPredicate that is active on the server side instead of in your app. If you want to validate if the predicate is correct, then just execute it as a query and see what you get back.
Make sure your application difFinishLaunchingWithOptions has the following lines of code:
Also make sure you handle incoming notifications by adding this: