嗨,我正在尝试保存对 iCloud 的订阅,我正在使用此代码:
func setupCKSubscriptions(){
if NSUserDefaults.standardUserDefaults().boolForKey("sub") == false{
let subscription = CKSubscription(recordType: "Quadri", predicate: NSPredicate(value: true), options: .FiresOnRecordCreation)
let notificationInfo = CKNotificationInfo()
notificationInfo.alertLocalizationKey = NSLocalizedString("NEW_Q", comment: "")
notificationInfo.shouldBadge = true
subscription.notificationInfo = notificationInfo
let modifyOperation = CKModifySubscriptionsOperation(subscriptionsToSave: [subscription], subscriptionIDsToDelete: nil)
modifyOperation.modifySubscriptionsCompletionBlock = {(_, _, errore) -> Void in
if errore == nil{
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "sub")
NSUserDefaults.standardUserDefaults().synchronize()
}else{
print(errore?.localizedDescription)
let alert = UIAlertController(title: "", message: errore?.localizedDescription, preferredStyle: .Alert)
self.presentViewController(alert, animated: true, completion: nil)
}
}
CKContainer.defaultContainer().publicCloudDatabase.addOperation(modifyOperation)
}
}
我收到此错误(仅当我使用 TestFlight 运行应用程序时):
修改部分订阅失败
我怎样才能解决这个问题?