首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未在MacCatalyst上调用didReceiveRemoteNotification

未在MacCatalyst上调用didReceiveRemoteNotification
EN

Stack Overflow用户
提问于 2020-02-14 15:21:00
回答 1查看 230关注 0票数 3

当我创建一个CKSubscription时,didReceiveRemoteNotification会在iOS上正常调用,但在MacOS上不会。我在2015年遇到了一个关于bug的帖子,建议的解决方法是将通知信息的soundName设置为空字符串-不幸的是,这并没有解决我的问题。

下面是我注册远程通知的方式:

代码语言:javascript
复制
  func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

        let subscription = CKQuerySubscription(recordType: "Reminder", predicate: NSPredicate(format: "TRUEPREDICATE"), options: [.firesOnRecordCreation, .firesOnRecordUpdate])

        // Here we customize the notification message
        let info = CKSubscription.NotificationInfo()

        info.shouldSendContentAvailable = true
        info.desiredKeys = ["identifier", "title", "date"]
        info.soundName = ""

        subscription.notificationInfo = info

        // Save the subscription to Private Database in Cloudkit
        CKContainer.default().privateCloudDatabase.save(subscription, completionHandler: { subscription, error in
            if error == nil {
                // Subscription saved successfully 
            } else {
                // Error occurred
            }
        })
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-27 05:20:22

这与Mac Catalyst上的捆绑包标识符不同有关。多亏了即将推出的通用应用程序购买,catalyst应用程序现在可以使用与iOS相同的捆绑包标识符,这解决了这个问题。

请注意,我也遇到了cloudkit密钥值在Mac (NSUbiquitousKeyValueStore)上不同步的问题。为Mac和iOS设置一个包id也解决了这个问题。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60221693

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档