Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reseting AWSConfiguration at runtime for PinpointManager #3659

Closed
gemasr opened this issue Feb 7, 2025 · 5 comments
Closed

Reseting AWSConfiguration at runtime for PinpointManager #3659

gemasr opened this issue Feb 7, 2025 · 5 comments
Labels
question General question

Comments

@gemasr
Copy link

gemasr commented Feb 7, 2025

Is it posible to reset the PinpointConfiguration in runtime?

Currently I am initializing the PintpointConfiguration as follows:


AWSMobileClient.getInstance().initialize(context, awsConfiguration, object: Callback<UserStateDetails> {
 override fun onResult(userStateDetails: UserStateDetails) {
   val config = PinpointConfiguration( 
      context,
      AWSMobileClient.getInstance(),
      AWSMobileClient.getInstance().configuration
    )
   pinpointManager = PintpointManager(config)
 }
...
}

This works fine but I need to change the configuration in runtime (I will have users whose data is sent to a different instance of Pinpoint based on their region) and it is always keeping the first configuration I have passed to it. So if for example I have an US user logged in and configure it with the us region instance, then if the user logouts and another user, in this case from EU region for example, logs in, it is keeping the US region even if I call this code again to reconfigure it.

Is there a way to make the PinpointManager to reconfigure in runtime? Thanks in advance!

Which AWS Services are you utilizing?

  • AWS Pinpoint

Environment(please complete the following information):

  • SDK Version: 2.76.1

Device Information (please complete the following information):
Not specific to a certain device

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify team member labels Feb 7, 2025
@tylerjroach
Copy link
Member

PinpointManager is not a singleton. You should just be able to create multiple instances of PinpointManager. If you need multiple credentials providers, you will have to manually provide your own, as I do not believe you can reset that singleton.

@tylerjroach tylerjroach added question General question and removed pending-triage Issue is pending triage labels Feb 7, 2025
@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 7, 2025
@gemasr
Copy link
Author

gemasr commented Feb 7, 2025

PinpointManager is not a singleton. You should just be able to create multiple instances of PinpointManager.

But I am already creating another instance every time I get a new configuration using this code:

AWSMobileClient.getInstance().initialize(context, awsConfiguration, object: Callback<UserStateDetails> {
 override fun onResult(userStateDetails: UserStateDetails) {
   val config = PinpointConfiguration( 
      context,
      AWSMobileClient.getInstance(),
      AWSMobileClient.getInstance().configuration
    )
   pinpointManager = PintpointManager(config)
 }
...
}

And it seems to keep just the first configuration I provide for the first client. Is there anything more I should do?

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 7, 2025
@tylerjroach
Copy link
Member

You cannot reconfigure AWSMobileClient, so the below will continue to yield the same results.

val config = PinpointConfiguration( 
      context,
      AWSMobileClient.getInstance(),
      AWSMobileClient.getInstance().configuration
    )
public PinpointConfiguration(
    final Context context,
    final AWSCredentialsProvider credentialsProvider,
    final AWSConfiguration awsConfiguration
)

You are using this constructor for the PinpointConfiguration. You would need to write your own extension of the AWSCredentialsProvider and provide another AWSConfiguration.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 7, 2025
@gemasr
Copy link
Author

gemasr commented Feb 7, 2025

Ahh I see! Thank you very much! We can close this question.

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 7, 2025
@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Feb 7, 2025
Copy link
Contributor

github-actions bot commented Feb 7, 2025

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question General question
Projects
None yet
Development

No branches or pull requests

3 participants