Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are public database subscription notifications received by all users with the same subscription?

Tags:

cloudkit

I have set up a CKSubscription* so that I receive changes to a record type.

I'm using the public database.

When I test with the same user (same iCloud account) I receive the notification.

If I use a different user (different iCloud account) I don't receive the notification.

Are subscriptions designed to only work between devices of the same user?

Here is the documentation that describes subscriptions:

Use a CKSubscription object to track changes occurring on the server. A subscription acts like a persistent query on the server that can track the creation, deletion, and modification of records. When changes occur, they trigger the delivery of push notifications so that your app can respond appropriately.

https://developer.apple.com/library/ios/documentation/CloudKit/Reference/CKSubscription_class/index.html#//apple_ref/occ/cl/CKSubscription

I would expect to receive a notification no matter which user edits the record, and subscription predicate should still match.

UPDATE

*Every user has a subscription with the same predicate, essentially focused on a single recordType with a particular property value.

The payload for this subscription is only to push shouldSendContentAvailable=YES.

The documentation reads:

When this property is YES, the server includes the content-available flag in the push notification’s payload. That flag causes the system to wake or launch an app that is not currently running. The app is then given background execution time to download any data related to the push notification, such as the set of records that changed. If the app is already running in the foreground, the inclusion of this flag has no additional effect and the notification is delivered to the app delegate for processing as usual.

The recordType's security permission is:

enter image description here

FURTHER UPDATE

Checked the logs of the device not receiving the push when it should and saw:

apsd[85]: Silent Push: Deny app not available

Rebooted the device and now it works fine!

like image 657
Vamos Avatar asked Mar 29 '15 14:03

Vamos


1 Answers

This behaviour was due to a mistake in how my CKSubscription was configured. If we want all users to receive notifications from the subscription then it should not have a zoneID set (should remain nil). I was setting the zoneID to the value from the defaultRecordZone, this will restrict the notifications to the current user only as the defaultRecordZone's user is the current user.

UPDATE

Finally solved the problem. Not only was it an issue of zoneID, but there also seems to be a bug. My subscription notificationInfo simply had shouldSendContentAvailable set to YES. This doesn't cause the subscription notification to fire for changes made by anyone other than the current user (u1d1->u1d2, but not u1d1>u2d2). I simply added an alertBody and the notifications start firing.

Anyone else face this issue?

UPDATE 2

Rebooting the device solved the issue.

like image 158
Vamos Avatar answered Nov 26 '22 05:11

Vamos