Cache issue on repositories when changing apiKey

Our App uses 2 Amity configs (both in US region, but we have 2 keys), and we have a set of users that will be able to jump between the two of them. They do so by login in and out with different user ids

So, depending on their region we will initialize the AmityCoreClient.setup with the corresponding key. And also, call unregisterDevice when they log out.

We also make use of CommunityRepository. Which is caching the communities between logins, so when a user jumps from one amity config to another, it gets to see the communities from both configurations. Can this be fixed, please?

Hello Franco,

The data supposed to be wiped when you called “unregisterDevice” function. May you please show me the code snippet when you call registerDevice, unregisterDevice, and setup ?

After a user logs in, we know their region, so we use that to initialize Amity:

                apiKey = region.getAmityKey(),
                httpEndpoint = AmityRegionalEndpoint.US,
                socketEndpoint = AmityRegionalEndpoint.US

And right after, the user:

                .displayName(displayName = user.username ?: "User")
                .doOnComplete {
                    Timber.w("Register complete // Amity")
                .doOnError {
                    Timber.w("Error Register// Amity")

We then call these two method on each app launch.

And when the users logs out we call:


Thank you Franco,
We will investigate the issue further and keep you updated.

Hello Franco,
We have investigated the issue and tried replicating the issue and can’t seem to reproduce. May you help us log if the unregisterDevice method is successfully executed by

               .doOnError { 
                 // log if it's error
               .doOnComplete {
                // log if it's completed
               .subscribe ()