How to handle Client Reset iOS

Hi,

I am going through the doc (https://docs.realm.io/sync/using-synced-realms/errors#client-reset) to handle client reset error and found it’s very confusing . I have two questions about the following code.

  1. First there is no method available to closeRealmsafely. can you please help me understand how can I close the realm safely?

  2. How can I backup and when I will use it?

  3. Should I skip the reset error because in documentation it’s mentions “if the client reset process is not manually initiated, it will instead automatically take place after the next time the app is launched, upon first accessing the SyncManager singleton. It is the app’s responsibility to persist the location of the backup copy if needed, so that the backup copy can be found later.”

Below is the error handler sample code from the doc.

SyncManager.shared.errorHandler = { error, session in

 let syncError = error as! SyncError

 switch syncError.code {

 case .clientResetError:

 if let (path, clientResetToken) = syncError.clientResetInfo() {

 closeRealmSafely()

 saveBackupRealmPath(path)

 SyncSession.immediatelyHandleError(clientResetToken)

 }

 default:

 // Handle other errors...

 ()

 }

}

Cross post to the same question on SO Realm iOS: How to handle Client Reset

It’s a good idea to keep questions in one place so any answers or activity is focused and we don’t do double duty when responding.

1 Like