swift Swift - CloudKit - 删除订阅

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift Swift - CloudKit - 删除订阅相关的知识,希望对你有一定的参考价值。

See:https://www.hackingwithswift.com/read/33/8/delivering-notifications-with-cloudkit-push-messages-ckquerysubscription

 let database = CKContainer.default().publicCloudDatabase

    database.fetchAllSubscriptions { [unowned self] subscriptions, error in
        if error == nil {
            if let subscriptions = subscriptions {
                for subscription in subscriptions {
                    database.delete(withSubscriptionID: subscription.subscriptionID) { str, error in
                        if error != nil {
                            // do your error handling here!
                            print(error!.localizedDescription)
                        }
                    }
                }

                // more code to come!
            }
        } else {
            // do your error handling here!
            print(error!.localizedDescription)
        }
    }

以上是关于swift Swift - CloudKit - 删除订阅的主要内容,如果未能解决你的问题,请参考以下文章

swift Swift - CloudKit - 获取用户ID

swift Swift - CloudKit - 推送通知

swift Swift - CloudKit共享

swift Swift - CloudKit - 维护本地缓存

swift Swift - CloudKit - 部署架构

swift Swift - CloudKit订阅 - 5