【问题标题】:How to send multiple columns of information using CKSubscription如何使用 CKSubscription 发送多列信息
【发布时间】:2016-03-19 18:02:27
【问题描述】:

我可以使用 CKNotificationInfo() 和 CKNotificationInfo.alertBody 获得 CKSubscription 工作。所以我可以发送一条信息。我正在尝试让 CKSubscription 以字典格式向用户发送消息、用户名、位置等信息。我已经涉足 CKNotificationInfo.alertLocaliztionKey 和 CKNotificationInfo.alertLocaliztionArgs 但似乎无法使其工作。感觉就像我错过了一些小东西,因为 CKSubscription 不应该让它工作起来那么麻烦。

【问题讨论】:

标签: ios swift apple-push-notifications cloudkit cksubscription


【解决方案1】:

因为这不是通知框架的意图。您得到的是关于 WHAT 已更改的信息,然后您必须获取这些数据并执行您想做的任何事情。我制作了一个应用程序,它既可以告诉用户某些事情发生了变化,又可以在后面静默刷新本地数据:

let cloudKitNotifiction = CKQueryNotification(fromRemoteNotificationDictionary: uif)
        if cloudKitNotifiction.notificationType == CKNotificationType.Query{
            if let recordId = cloudKitNotifiction.recordID{
                let ccs = CloudCoreSynchronizer()
                ccs.syncOneCustomerFromCloudToCore(recordId)
                resetBadgeCounter()
            }
        }

如果您希望在应用程序处于后台时发生这种情况,您必须启用推送通知和后台模式。希望这会有所帮助。 PS:inapp购买的东西就不管了,和这个没有关系

【讨论】:

    猜你喜欢
    • 2014-01-30
    • 2011-06-26
    • 2011-01-11
    • 2013-05-31
    • 1970-01-01
    • 1970-01-01
    • 2021-03-24
    • 1970-01-01
    • 2017-10-30
    相关资源
    最近更新 更多