I use CloudKit. I have a Channel
record type which does have isLive
as an attribute. It can be either 0
or 1
indicating if the channel is live.
I want to send a notification to all users if the live status if a channel changes from 0 to 1.
I tried to define the CKQuerySubscription like this:
let liveSubscription = CKQuerySubscription(recordType: "Channel", predicate: NSPredicate(format: "(recordID == '4cebe441-c6f7-47af-85df-e6572e757c5c') AND (isLive == 1)"), options: [.firesOnRecordUpdate])
let liveNotificationInfo = CKNotificationInfo()
liveNotificationInfo.shouldSendContentAvailable = false
liveNotificationInfo.shouldBadge = true
liveNotificationInfo.alertBody = "Test is live now"
channelSubscription.notificationInfo = liveNotificationInfo
This does send a notification on any update of this channel record though. It does not care about the isLive
predicate.
Any idea how can I receive notifications only for isLive
change from 0 to 1?
Or is it better to receive all updates on this channel record, process them in my app and then send a local notification if necessary?