Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudKit push notification subscription not working

I'm trying to subscribe to push notifications using CloudKit. I'm getting this error:

<CKError 0x170c5b1e0: "Unknown Item" (11/2003); server message = "could not find required field fieldID="25""

from this code:

let subscription = CKSubscription(recordType: "PlayerData", predicate: NSPredicate(format: "TRUEPREDICATE"), options: CKSubscriptionOptions.FiresOnRecordCreation)
let notificationInfo = CKNotificationInfo()
notificationInfo.shouldBadge = false
subscription.notificationInfo = notificationInfo
PublicDb.saveSubscription(subscription, completionHandler: { (returnedSubscription: CKSubscription!, error: NSError!) in
     println("\(error)")
})

But I don't have a field called "fieldID" nor I have any kind of reference to it in my entire project. I don't know where the 25 comes from either. It still happens if I change my record type and/or NSPredicate.

I also tried setting this but nothing

notificationInfo.shouldSendContentAvailable = true

This used to work for me, but now I cannot make it work anymore. Seems like my database got corrupted somewhere. I tried deleting the record type and recreating but no luck.

like image 659
Genki Avatar asked Mar 12 '15 17:03

Genki


2 Answers

Fixed it by resetting the development environment. Hopefully same thing doesn't happen on prod. enter image description here

like image 100
Genki Avatar answered Sep 18 '22 21:09

Genki


This same thing just happened to me. I don't think fieldID is due to someone else's database, but rather part of Apples underlying database structure. Unfortunately that read-out gives us developers zero information. The resetting of the development environment fixed my issue as well. Worth noting that this happened after changing the attribute type of a record that was specifically being referenced in a subscription. I had kept the attribute name but changed its type.

like image 43
Daniel Popov Avatar answered Sep 19 '22 21:09

Daniel Popov