Force Session Restart in Swift

Flexible Sync is configured and works … I store accountIds in custom_data.accountIds that limit which accounts a user can see. Uses can only see the ones defined there. As I understand, these changes (ie, add an additionl account that a user can see) will only take affect on the next sync session.

How do I force a new sync session? (I am not worried about detecting this change on the client, I just want to run it when I know there is a change).

I have tried the following (suggestion I have seen in other posts)…

realm.syncSession?.suspend()
try! await app.currentUser!.refreshCustomData()
realm.syncSession?.resume()

but this has not been successful in showing the newly added account. If I restart the app, it will usually cause the subscription to be reset and all works fine. How can I reset a subscription manually without making the user restart or login/logout?

Hi @Robert_Charest,

By default, the SDK will allow multiple sessions to share a connection, so pausing & resuming a session does not guarantee that the permissions on the connection are refreshed. We have an improvement scheduled to refresh the permissions on each new session which will provide the behavior you’re looking for. This should be available in the next few weeks.

it will usually cause the subscription to be reset and all works fine

Also, keep in mind that under the hood a change in permissions like this will trigger a client reset.