gpt4 book ai didi

iOS 未收到来自 CloudKit 的推送通知

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:34:11 25 4
gpt4 key购买 nike

我正在尝试为 CloudKit Records 设置订阅,订阅创建成功,我可以使用 CKFetchSubscriptionsOperation 成功检索它。但是函数
application(_:didReceiveRemoteNotification:)
没有被调用...(我正在仪表板中手动更改记录)

订阅是这样设置的:

let database = CKContainer.default().privateCloudDatabase
let subscription = CKSubscription(recordType: "Device", predicate: NSPredicate(format: "TRUEPREDICATE"), options: .firesOnRecordUpdate)

let notificationInfo = CKNotificationInfo()
notificationInfo.alertLocalizationKey = "DEVICE_UPDATED"
notificationInfo.alertBody = "Device updated in database"

subscription.notificationInfo = notificationInfo

database.save(subscription) { subscription, error in
if error != nil {
print(error?.localizedDescription as Any)
} else {
print(subscription)
}
}

通知的注册注册是:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {        
let notificationSettings = UIUserNotificationSettings(types: [.alert, .badge], categories: nil)
application.registerUserNotificationSettings(notificationSettings)
application.registerForRemoteNotifications()

return true
}

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
print(userInfo)
}

最佳答案

好的,我必须启用推送通知并生成“Apple 推送通知服务 SSL 证书”并将其附加到我在 Apple Developer Provisioning Profiles 页面上的应用

关于iOS 未收到来自 CloudKit 的推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41902445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com