Realm SyncSession
object has a addProgressNotification
method https://github.com/realm/realm-cocoa/blob/b606bfddaa0856489561727207e755659faa9a7e/RealmSwift/Sync.swift#L557 so a callback can be added there to update a local date property to store the last synced realm updated time.
Realm user object contains a list of active sessions that can be accessed via user.allSessions
and alternative is realm.syncSession
.
let realm = realmProvider.realm
let progressTokenDownload = realm.syncSession?.addProgressNotification(
for: .download,
mode: .forCurrentlyOutstandingWork
) { progress in
print(">>> DEBUG: [DCSettingsViewModel:checkRealmSyncingStatus] download", progress.fractionTransferred)
}
let progressTokenUpdate = realm.syncSession?.addProgressNotification(
for: .upload,
mode: .forCurrentlyOutstandingWork
) { progress in
print(">>> DEBUG: [DCSettingsViewModel:checkRealmSyncingStatus] upload ", progress.fractionTransferred)
}
if let progressTokenUpdate = progressTokenUpdate, let progressTokenDownload = progressTokenDownload {
progressNotificationTokens.append(progressTokenUpdate)
progressNotificationTokens.append(progressTokenDownload)
}