Offline PDF Annotations with Sync on Android

PSPDFKit Instant is designed to be fully functional while a device is offline or a connection is unreliable. Users can continue to create and edit annotations, and Instant will automatically sync these later when a connection is available.

Instant stores annotations in a local database on the device and then synchronizes this with your Document Engine instance as soon as a connection is available.

If two or more users edit the same annotation while being offline, this creates a conflict. In such situations, Instant applies a first-come-first-win resolution strategy and will only accept the annotation changes of the first client that submits them to the server. All other clients will discard their local changes to the annotation and will apply the changes submitted by the first client.

If Instant is trying to sync but the device is offline, it will report the errorInstantErrorCode.REQUEST_FAILED. Your app can respond to this in whichever way you find appropriate: This is typically done by updating the user interface to indicate that annotations cannot be synchronized.

Since there’s no way to know for sure if a connection is possible without first trying, Instant may still attempt to synchronize annotations when there’s no connection. If you present synchronization errors as alerts to the user, we recommend filtering out this error code, because users are familiar with connectivity problems and they expect apps to sync data automatically when a connection is available.