aws-amplify / aws-sdk-android

AWS SDK for Android. For more information, see our web site:
https://docs.amplify.aws
Other
1.03k stars 549 forks source link

AWSMobileClient reset feature #1348

Open kraakk001 opened 4 years ago

kraakk001 commented 4 years ago

Which AWS Services is the feature request for? The AWSMobileClient for Android.

Is your feature request related to a problem? Please describe. We are currently developing an Android application that uses the AWSMobileClient. We are retrieving our awsconfiguration.json from an API to support multiple companies with different stacks.

We use the altered AWSConfiguration that supports a JSONObject now. Unfortunately when we want to switch between companies, we have to kill the application to reset the AWSMobileClient.

This is caused by the AWSMobileClient. Once the AWSMobileClient (Singleton) is initialized, re-initializing will always ignore the new AWSConfiguration. As can be seen in AWSMobileClient.java line 451. See "Additional context" for a screenshot.

Describe the solution you'd like So we'd like to request a reset() method to reset the initialized AWSMobileClient to it's initial state. (Which also resets the IdentityManager and any other initialized fields)

By briefly checking the code, it could also be achieved by comparing AWSMobileClient.this.awsConfiguration with the passed parameter of the _initialize method and if they have a different JSONObject/body the condition of line 451 should return false. Thus resulting in a newly initialized instance of the AWSMobileClient and the IdentitityManager.

Describe alternatives you've considered I've tried keeping the passed Configuration object in Memory in another SIngleton and altering that one to be 'NULL', hoping that it would update the AWSConfiguration object of the AWSMobileClient. So I could reset it that way, before calling initialize on the AWSMobileClient.

Additional context image

jayadeep40 commented 4 years ago

I'm facing the same issue and there was no reset method in AWSMobileClient to reset the aws instance. i'm using aws-android-sdk-mobile-client:2.8.+@aar as the dependency in my android application. Thanks in Advance