Adding role to SG user does not trigger replication

We have a setup where in order for one user to share a document with another user, we create a role that has an associated channel which the sync function assigns to the document (via a property on the document, e.g. the _id). This is done via a call to our internal API which uses the Sync Gateway admin API to create the role and associate the documents channel with that role.

When a user accepts the shared document (also via our internal API and then the sync gateway admin Rest API), the role is added to that user. We can see from the Sync Gateway web interface that the Sync Gateway user has the associated role at the moment they accepted the share. So at this point, everything has worked as expected.

However, the document corresponding to that channel is not (always) being synced to the couchbase lite running on the iOS which which triggered the API call (as the authenticated user with the channel’s corresponding role) to accept the shared document. The problem seems to appear more times than it doesn’t, although we have seen a small number of incidents where the replication happened and the document arrived on the users local device.

Also, if our app is purged from the device and the user re-authenticates with Sync Gateway, the shared document successfully appears.

We have found this
which seems potentially relevant. Do you have any advice on how we can work around this issue?