I am trying to use CKSubscription
this way:
NSArray *events = @[@1,@2,@3];
NSInteger myValue = 100;
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"(value > %@) AND (prev_value < %@) AND (event_type IN %@)",
@(myValue), @(myValue), events];
CKSubscription *sub = [[CKSubscription alloc] initWithRecordType:@"TableName"
predicate:predicate options:(CKSubscriptionOptionsFiresOnRecordCreation)];
[db saveSubscription:sub completionHandler:^(CKSubscription *s, NSError *error) {
if (error) {
NSLog(@"Error: %@", error.localizedDescription);
return;
}
NSLog(@"Success!");
}];
This getting me error:
Error: Error saving record subscription with id 781FB482-C9C9-4DA5-8022-CFDB8006223A to server:
invalid attempt to set value type NUMBER_INT64 for field 'binding_0' for type
'_sub_trigger_sub_220b17724b5262b0590a3c9d66be9826', defined to be: INT64_LIST
This looks like valid NSPredicate
can not be properly stored in CloudKit as part of CKSubscription
object. It that real Apple bug or mine?
P.S. I have tried a lot of different combinations by removing different parts of predicate condition. Looks like the only condition for event_type
works fine, but when I am mixing 3 conditions with AND
- this causes a problem.
P.P.S. I am using Xcode 6 beta 6
on OSX 10.10 DP6
and iOS8 beta 5
on iPhone 5S
UPDATE:
Subscriptions with one of the following predicates works fine:
NSPredicate *predicate1 = [NSPredicate predicateWithFormat:
@"(value > %@) AND (prev_value < %@)", @(myValue), @(myValue)];
NSPredicate *predicate2 = [NSPredicate predicateWithFormat:
@"(event_type IN %@)", events];
But saving subscription with common predicate fails:
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"(value > %@) AND (prev_value < %@) AND (event_type IN %@)",
@(myValue), @(myValue), events];
Looks like real Apple CloudKit bug. Just opened issue at bugreport.apple.com #18105879
UPDATE 2:
Thanks to @purrrminator - here are two radars with problem with receiving CloudKit push notifications:
http://openradar.appspot.com/18807663
http://openradar.appspot.com/18798061
I found workaround for saving CKSubscription
properly via presenting IN
condition with a lot of equality comparers. But really I got no push notifications from CLoudKit...