0
我使用CloudKit。我有一個Channel
記錄類型,它具有isLive
作爲屬性。它可以是0
或1
,指示頻道是否有效。如何創建CloudKit訂閱通知以在記錄屬性更新上觸發?
我想將通知發送給所有用戶,如果在從0頻道更改爲1
我試圖這樣定義CKQuerySubscription實時狀態:
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
這併發送雖然這個頻道記錄的任何更新通知。它並不關心謂詞。
任何想法我怎樣才能收到通知只爲isLive
從0改爲1?
或者是收到此頻道記錄的所有更新,在我的應用程序中處理它們,然後在必要時發送本地通知?
嗨有任何解決方法?它也不適合我。 –