CKSubscription错误

时间:2016-03-10 19:33:06

标签: swift push-notification icloud cksubscription

您好我正在尝试保存订阅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运行应用程序时):

  

无法修改某些订阅

我该如何解决这个问题?

0 个答案:

没有答案