Check if synced Realm has pending changes waiting to be uploaded

Hi, I’m working on an offline-first application. Is there a way of determining if the app has any unsynced data whilst the app is offline? It could be used to display a banner to notify that they’ll need an active internet connection to sync the data back to the database, and it would be useful to show an alert before they logout too.

I know that Realm has a syncSession.addProgressNotification function to register a callback, but it doesn’t look like it’s fired if the app is launched whilst offline. This is what I tried:

const Banner = () => {
  const [transferred, setTransferred] = useState(0)
  const [transferable, setTransferable] = useState(0)

  const realm = useRealm()

  useEffect(() => {
    const progressListener = (transferred: number, transferable: number) => {


    return () => {
  }, [realm._instance.syncSession])

  const show = useMemo(() => transferred < transferable, [transferred, transferable])

  if (!show) return null

  return <Text>You have unsynced data</Text>

The above works great if you start the app and you’re online, go offline, create some data, and return online. But if you start the app offline, the banner returns null. If you toggle the connection again it works as expected.

If it helps, I’m using flexible syncing and not partition-based syncing.

Realm version: 11.10.1
realm-react version: 0.6.0