The CKSubscription documentation says: When a record modification causes a subscription to fire, the server sends push notifications to all devices with that subscription except for the one that made the original change to the record.
Let's assume I have two devices: device 1 an iPad and device 2 an iPhone both logged in with the same iCloud accounts. Let's assume both devices subscribe for record updates for a certain record type.
My code looks like this (I've taken out some of the housekeeping stuff)
NSPredicate *predicate2 = [NSPredicate predicateWithFormat:@"fromUserRecordIDName == %@", _member.userRecordIDName];
NSPredicate *predicate2 = [NSPredicate predicateWithFormat:@"fromUserRecordIDName == %@", notificationPublic = [[CKNotificationInfo alloc] init];
notificationPublic.shouldBadge =YES;
notificationPublic.desiredKeys = @[@"fromMemberNameText"];
notificationPublic.shouldSendContentAvailable = YES;
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"TickleRecordUpdateSubscription"] == nil) {
[cloudManager subscribe:@"TickleRecord" public: YES options:CKSubscriptionOptionsFiresOnRecordUpdate predicate:predicate2 notification:notificationPublic completionHandler:^(CKSubscription *subscription, NSError *operationError) {
if (operationError) {
NSLog(@"An error occured in %@: %@", NSStringFromSelector(_cmd), operationError);
} else{
[[NSUserDefaults standardUserDefaults] setObject:subscription.subscriptionID forKey:@"TickleRecordUpdateSubscription"];
[[NSUserDefaults standardUserDefaults] setObject:@"TickleRecordUpdateSubscription"forKey:subscription.subscriptionID ];
}
}];
It seems to me that when one device updates a record, the other device should be notified. But that is not what is happening - there is no notification. In the WWDC 2014 Advanced iCloud video they talk about being notified when one device marks a notification as read, but I haven’t had any success with that either.
Has anyone been successful in notifying one device when another device signed into the same account updates a record it?