typescriptlibs/tsl-apple-cloudkit

Query subscription doesn't return a CloudKit.Notification

Closed this issue · 4 comments

I successfully save a subscription. Then I call addNotificationListener, whose argument is a function which takes a CloudKit.Notification. But instead of that, I'm seeing an object that looks like this:

{
    aps
    {
        content - available: 1
    },
    ck:
    {
        aux:
        {},
        ce: 2,
        cid: "<MY ID>",
        ckuserid: "<MY USER ID>",
        met:
        {
            dbs: 1,
            sid: com.apple.coredata.cloudkit.private.subscription",
            zid: "com.apple.coredata.cloudkit.zone",
            zoid: "_85bc87478f3f4b2674583752b91e8249"
        },
        nid: "4a65fb63-98ea-4710-a41e-6d479c63aa41"
    }
}

I have a CloudkitService, which contains the Container. So I'm calling it like this

  this.cloudKitService.container?.addNotificationListener(
    (notification: CloudKit.Notification) => {
      this.onNotificationListener(notification);
    }
  );

But notification is the above object, not a CloudKit.Notification.

This looks like a silent notification. I do not know, if they are supported in CloudKit JS. Did you created the subscription in CloudKit JS or over regular CloudKit?

Created in JS. interestingly I removed the zone id from the subscription and then I got a valid Cloudkit notification but I still get these weird ones.

I hate resolutions like this, but after returning to this project, I've noticed it's suddenly working again. Not really sure what was causing this, but I'm going to close this.

Thank you for the update. Glad to hear that this part is working.

The issue might have been triggered by a mixup of authentication tokens (a user has for each platform [iOS/macOS/JS] a different set, the container ID and Apple ID stay the same).
It is also possible that CloudKit had a bug that has been fixed in the meantime.
Anyway, it works now. 👍