Realm stops syncing silently

Hi All,

I have been investigating this problem for a number of months now, to no avail. I have also raised a support ticket, and come to a conclusion that I thought may have solved the issue. I am now, however, thinking there may be greater underlying issues present.

I have an iOS app where users must authenticate using Sign in with Apple (no other options at this point). At the time the app was released on the App Store, it was running realmSwift 10.16.0.

Once a user signs in (initially, after first downloading the app), they are able to both sync to the cloud and their local device successfully. This works as expected for what appears to be approx. 60 days. Then, after this time, the sync stops working. Data is still however being saved to the users’ local realm. There is no notification of the sync stopping or any error occurring in our server-side logs, and there appears to be no failure on the client side - everything appears to be business as usual.

After raising a ticket with support, myself and the support engineer concluded that the refresh token was not automatically being refreshed as it was supposed to. This was caused by a bug in the version of realmSwift we were running (10.16.0). It was suggested that I update to the current version to fix this issue.

I updated to the latest version of realmSwift and am currently going through testing in my dev env, which also includes so changes to the way I am handling a client reset (somewhat unrelated info). I am wanting to try to now deliberately replicate what is happening in production to check that I have fixed the issue by updating realmSwift.

I have attempted to replicate this behaviour by “Revoke all sessions” (under App Users) for a test user. I have also tried app.currentUser?.logOut, but both result in the user not being able to save to their local realm in addition to not being able to sync to the cloud.

As an extra bit of info (if it helps as a clue for someone), if a user were to go to their device Settings → Passwords & Security → Apps using Apple ID → “APP_NAME” → Stop using Apple ID → then logs in to the app again, sync is regained.

Can anyone tell me is it expected that if a user refresh token expires, the only consequence is the user being unable to sync data to the cloud (ability to save data to the local realm is unaffected)?

Can anyone suggest a way to replicate the behaviour of an expired refresh token in my case where I am only using Sign in with Apple?

Thanks for reading, I’m more than happy to provide more info if need be.