Realm not Synch after long background


#1

I have a Xamarin App both in iOS and Android that at the beginning syncs the Realm with GetInstanceAsync. Everything works best when the Apps are active or when they are shooting quickly from the background. But when I spend a lot of time and I resume an App from the background and make changes, these are not synchronized on the server. I have to call the GetInstanceAsync method to synchronize everything again. Is there any method I need to call on OnResume ()? Realm.Refresh?
Thanks for the support!


#2

It’s hard to answer my question?


#3

@luigi.degiacomo No there is no OnResume or Refresh methods. As long as you hold a strong realm reference that is returned from GetInstanceAsync open - the sync will work automatically. Make sure you are not dispatching writes to background threads because those threads do not have the event loop running on it so the updates will not automatically propagate. You can see a working Xamarin example here -
https://docs.realm.io/sync/getting-started-1/xamarin-quick-start


#4

There’s also a Session.Reconnect() method that may be what you’re looking for.