OS X CloudKit App Not Receiving Subscription Notifications

Originator:aaron
Number:rdar://23804473 Date Originated:08-Dec-2015 01:25 PM
Status:Open Resolved:
Product:OS X Product Version:OS X 10.11.1
Classification:Other Bug Reproducible:Always
 
Summary:
Recently, my Mac OS X app using CloudKit subscriptions stopped receiving change notifications. I have filed a DTS incident #631119498 to help resolve it. I was asked to file a radar as they appear to suspect an issue with the CloudKit infrastructure.

Steps to Reproduce:
What I've done:

1. Save a separate subscription for each of CREATE, UPDATE and DELETE actions. My CKNotificationInfo objects look like this:

- (CKNotificationInfo *)notificationInfo {
    CKNotificationInfo *note = [[CKNotificationInfo alloc] init];
    note.alertBody = @"";
    note.shouldBadge = NO;
    note.shouldSendContentAvailable = YES;
    note.soundName = @"";
    return note;
}

I then save the subscription if it hasn't been saved before using this code:

CKSubscription *sub = [[CKSubscription alloc] initWithRecordType:@"Video" predicate:[NSPredicate predicateWithFormat:@"TRUEPREDICATE"] subscriptionID:ident options:options];
    sub.notificationInfo = [self notificationInfo];
    
    CKContainer * myContainer = [CKContainer containerWithIdentifier:@"iCloud.com.innoveghtive.VideoGrabber"];
    CKDatabase * privateDatabase = [myContainer privateCloudDatabase];
    
    [privateDatabase saveSubscription:sub completionHandler:^(CKSubscription *subscription, NSError *error) {
        if (error) {
            NSLog(@"SUBSCRIPTION ERROR! %@", error);
        }
        else {
            NSLog(@"Sub successful for %@", ident);
        }
    }];

The subscriptions are saved successfully.

2. I register for the push notifications in my Mac app's AppDelegate. I want it to be a silent notification, so I choose that setting:

[NSApp registerForRemoteNotificationTypes:NSRemoteNotificationTypeNone];

I also wrote the delegate methods to check whether I registered:

- (void)application:(NSApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    NSLog(@"Succeed register with token = %@", deviceToken);
}

That also works every time.

3. I deploy the delegate method to respond to notifications:

- (void)application:(NSApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    [self.windowVC didReceiveNotification:userInfo];  
}

This method is never called.

I have tried a great variety of different techniques and notification info configurations, but nothing takes. 

Expected Results:
My Mac app should receive notifications.

Actual Results:
No notification is received.

Notes:
If you are able to check 631119498 with the DTS team you can see the ongoing discussion around the things we’ve tried to fix this.

In the meantime I have updated my app to periodically check CloudKit for data changes, and that is working fine, if inelegantly.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!