CloudKit 记录更新推送通知停止工作 [英] CloudKit push notifications on record update stopped working

查看:26
本文介绍了CloudKit 记录更新推送通知停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:今天 27.08.2015 重新测试,它再次工作,Apple 已修复它.

EDIT: Retested today 27.08.2015 and it works again, Apple has fixed it.

我有一个应用程序处于开发模式.该应用程序使用 CKSubscription 来获取有关服务器更改的通知,针对所有三个选项进行配置:创建、更新、删除.一切正常,但最近在回归测试期间,我发现该应用程序没有收到有关记录更新的通知,创建和删除通知仍在工作.当我在仪表板上检查时,所有三个选项的订阅类型都正确设置,并且应用程序已注册 CKSubscription,就像几天前它像魅力一样工作时一样.我没有从 CloudKit 收到任何错误.开发环境的重置没有帮助.我已经使用我确定它可以正常工作的版本进行了重新测试,并得到了相同的结果.

I have an application in development mode. The application uses CKSubscription to get notified on changes on the server, configured for all three options: create, update, delete. Everything was working fine but recently during regression tests I have discovered the application does not receive notifications on record updates, the create and delete notifications are still working. The susbcription types are set correctly for all three options as I checked on the dashboard and the application is registered for CKSubscription as it was a couple of days ago when it was working like charm. I am not getting any errors from CloudKit. The reset of development environment did not help. I have re-tested with the version with which I am sure it was working and got the same results.

知道可能导致此问题的原因是什么,我还应该检查/尝试什么?

Any idea what might be causing this issue, what else should I check / try?

附加信息:我想服务器端可能会出现问题.我没有更改订阅 CloudKit 事件和处理推送通知的代码中的任何内容 - 无论如何,它工作的版本也不再收到更新通知.我正在处理的应用程序已发布,因此无法更改容器.不确定这是否可能导致问题,只想提一下:应用程序使用相同的容器将核心数据存储在云中 - 应用程序升级的目标是将数据迁移到 CloudKit 并将其用作云存储专用.令人困惑的是,一切都正常运行了数周,但突然停止工作,没有任何明确的原因,可能是密集测试负载的影响,添加记录类型......

Additional Info: I guess something might go wrong at the server side. I have not changed anything in the code where I am subscribing for CloudKit events and handling push notifications - anyway also the version where it was working is not getting update notifications any longer. The application I am working on is published, thus changing container is no go. Not sure if this might be causing the issue, just want to mention: the app is using the same container for storing the Core Data in the cloud - the goal of the app upgrade is to migrate data to the CloudKit and use it as the cloud storage exclusively. It is confusing that everything was working fine for weeks and suddenly stopped working without any clear reason, probably as the effect of the load by intensive testing, adding record types...

使用从头开发的应用进行测试:我编写了一个简单的测试应用程序来检查接收通知.我只能收到有关记录创建的通知.我的代码有什么问题:

Test with app developed from scratch: I have written a simple test app to check receiving notifications. I can receive only the notification on record creation. What is wrong with my code:

import UIKit
import CloudKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

let container = CKContainer.defaultContainer()

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    let settings = UIUserNotificationSettings(forTypes: .Alert, categories: nil)
    application.registerUserNotificationSettings(settings)
    application.registerForRemoteNotifications()

    return true
}

func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
    println("didFailToRegisterForRemoteNotificationsWithError: \(error)")
}

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
    println("didRegisterForRemoteNotificationsWithDeviceToken: \(deviceToken)")
    subscribe()
}

func subscribe() {
//        let predicate = NSPredicate(format: "text != %@", argumentArray: [""])
//        let predicate = NSPredicate(format: "TRUEPREDICATE", argumentArray: nil)
    let predicate = NSPredicate(value: true)
    let subscription = CKSubscription(recordType: "Note", predicate: predicate, options: .FiresOnRecordDeletion | .FiresOnRecordUpdate | .FiresOnRecordCreation)
    let notificationInfo = CKNotificationInfo()
    notificationInfo.alertBody = ""
    subscription.notificationInfo = notificationInfo
    let publicDatabase = container.publicCloudDatabase
    println("subscribing with CloudKit...")
    publicDatabase.saveSubscription(subscription, completionHandler: { (returnedSubscription, error) -> Void in
        if let error = error {
            println("subscription error \(error.localizedDescription)")
        } else {
            println("subscription ok")
        }
    })
}

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
    let ckNotification = CKQueryNotification(fromRemoteNotificationDictionary: userInfo)
    println("didReceiveRemoteNotification: \(ckNotification)")
}

func applicationWillResignActive(application: UIApplication) {}

func applicationDidEnterBackground(application: UIApplication) {}

func applicationWillEnterForeground(application: UIApplication) {}

func applicationDidBecomeActive(application: UIApplication) {}

func applicationWillTerminate(application: UIApplication) {}

}

推荐答案

我过去曾经历过这种行为.在我的情况下,我可以通过删除订阅并重新创建来解决它.您应该从代码而不是仪表板中做到这一点.从信息中心执行此操作仅适用于您登录信息中心的帐户.

I have experienced this behavior in the past. In my case I could solve it by just deleting the subscription and creating it again. You should do that from code and not the dashboard. Doing it from the dashboard only works for the account that you are loged in into the dashboard.

这篇关于CloudKit 记录更新推送通知停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆