Skip to main content

Restore on Device

Fetch Books#

TBD: Описание зачем делать fetch

To fetch user books, you need to call:

let booksRepository = BooksRepository()booksRepository.getBooks { (result) in    switch result {    case .success(let books):        // display a list of books and provide books for selection    case .failure(_):        // your implementation    }}

Begin Restore#

TBD: Нужно детальней описать пример

To restore contacts, you need to call: books - list of user books from which contacts should be restored.

CloudikeContacts.shared.restoreProcessor.restore(from: books) { (success, error) in }

Monitoring#

To monitor the restore status, you need to call:

CloudikeContacts.shared.restoreProcessor.registerObserver(observer)

To cancel monitoring, you need to call:

CloudikeContacts.shared.restoreProcessor.unregisterObserver(observer)

TBD: Описание прогресса рестора, стрктура нотификаций и значение

The following example shows how to do that:

class RestoreProgressViewController: UIViewController {    override func viewWillAppear(_ animated: Bool) {        super.viewWillAppear(animated)        CloudikeContacts.shared.restoreProcessor.registerObserver(self)    }
    override func viewWillDisappear(_ animated: Bool) {        super.viewWillDisappear(animated)        CloudikeContacts.shared.restoreProcessor.unregisterObserver(self)    }}
extension RestoreProgressViewController: RestoreObserver {    func restoreStateChanged(state: RestoreProcessor.RestoreState) {        // your implementation    }    }