How can I poll the current state of sync progress?

Here’s my scenario:

  1. User signs-in online
  2. Device goes offline
  3. User adds/modifies objects in local app DB
  4. User expects a UX/UI in app to indicate there is pending data waiting to sync.

Tried:

let session = appSession.userRealm?.syncSession
uploadToken = session?.addProgressNotification(for: .upload,
                                        mode: .reportIndefinitely) { progress in

    DDLogVerbose("sync progress (.upload): \(progress.fractionTransferred*100.0)")

    if progress.isTransferComplete {
        self.uploadToken?.invalidate()
    }
}

Nothing happens. :frowning:

How can I poll the current state of sync progress?

How did you go Sebastian? We’re attempting do something similar - providing an indication of the synchronisation status with a small progress bar in the header. Without this, our UX testing shows users are confused with data constantly changing whilst synchronisation is taking place, especially with a dashboard type view.

We had planned to use the addProgressNotification callback, and compare the percentage of bytes transferred vs transferable, though this seems to be firing the callback for every set of objects that’s been updated, thus it’s usually at 100% as the object data is relatively small.

It appears approx every second, the next item in the sync queue is processed, so it takes a long time with data jumping around on screen and extra overhead on client-side graph generation too. Users could be waiting minutes / or up to an hour depending on how much data needs to be synchronised.

Can anyone from MongoDB advise how to provide a progress indication of synchronisation? Seems like a pretty important use case for a platform with slow processing of synchronisation data (every second or so during our tests).