Reputation: 346
I make sync between CoreData and iCloud(CloudKit). How i can check if user switched iCloud account?
Other problem:
The user uses my app with iCloud account "A". He addes data. All data will copy in CKContainer "A". If user will switch account on iCloud account "B". I will add current data in new CKContainer "B".
But if user return back iCloud account "A", I need add current data from CKContainer "B" to CKContainer "A" without duplicates. How to solve a problem??
Upvotes: 0
Views: 175
Reputation: 3089
Add an observer within your app for Notification.Name.CKAccountChanged
, then clear local data and pull from iCloud again.
NotificationCenter.default.addObserver(forName: .CKAccountChanged, object: self, queue: nil) { notification in
...
}
Upvotes: 0