Open sagar-sable opened 2 years ago
@sagar14791 this is not currently possible so marked this as a feature request.
@ragingsquirrel3 is there any workaround besides app restart?
@ragingsquirrel3 Amplify.reset(); gives error "The member 'reset' can only be used within 'package:amplify_flutter/src/amplify_impl.dart' or a test."
Sorry for the confusion here. To clarify, runtime re-configuration is not currently supported in the underlying iOS/Android libraries. We are tracking this as a feature request here and will post further updates there.
@dnys1 is this feature going to get added anytime soon?
I am going to re-open this issue. This was closed as a duplicate of #1208. While there are similarities between the two requests, they do seem to be distinct.
We will use this issue to track interest in the ability to re-configure Amplify at run time. That is, call Amplify.configure() multiple times.
This feature is not currently on our roadmap. If you would like to see this supported, please comment with details about your use case. Thanks.
I want to describe our use-case: We are offering our app in the european union and in the US. With the EU having the GDPR (data privacy law), we have duplicated our entire AWS infrastructure and are basically running a mirrored setup in eu-central-1 and us-east-1. In our flutter app the user has the option to switch between the two regions on the very first screen, which is why we would need a reconfigure() call, that allows the user to, for example, swap back from a selected us-east-1 to eu-central-1.
@Jordan-Nelson Thank you for re-opening this issue I have One application that I am using for data collection offline and online, for Online data Collection and sync to amplify I am using the following Configuration.
Future<void> _configureAmplifyOnline() async {
await Amplify.addPlugins([
AmplifyDataStore(modelProvider: ModelProvider.instance),
AmplifyAPI(), // to connect to amplify
]);
await Amplify.configure(amplifyconfig);
}
for Offline data Collection and storing data Offline, I am using the following Configuration.
Future<void> _configureAmplifyOfflnine() async {
await Amplify.addPlugins([
AmplifyDataStore(modelProvider: ModelProvider.instance), //only to store data in oflline
]);
await Amplify.configure(amplifyconfig);
}
now when I am online and collecting data all works fine, as soon as I enter data it goes to the datastore and gets synced to amplify, but if all of a sudden I went offline due to a network issue, My data will get saved in the datastore and won't be synced, later when the network is there data will get synced as in my Online configuration I have AmplifyAPI(); Plugin. Condition 1: If I have to send my user to areas where there is no network available, he or she will sync data(Daily Tasks) from Amplify to a Mobile device at Office or where Network is available i.e Delta sync, sync will happen once every day then they may close the application, after on-field, if they start the application again they will have 2 Options to select Continue in Online ( which will again sync data and it will add AmplifyAPI(); in current configuration) or In Offlince which will not Sync data (but it will not add AmplifyAPI(); in the configuration which will stop data sync from device to server) then they will start the journey
at the end of the day when they will reach the office or any time of the day they have access to the network, they should be able to Sync data for that, there is a button in the application for data syncing, which should be able to change the configuration of Amplify from Offline
await Amplify.addPlugins([
AmplifyDataStore(modelProvider: ModelProvider.instance),
]);
to Online
await Amplify.addPlugins([
AmplifyDataStore(modelProvider: ModelProvider.instance),
AmplifyAPI(), // to connect to amplify
]);
So basically, I should be able to change the configuration of Amplify on demand. it can be region based or just basic Configuration.
@ragingsquirrel3 @dnys1 @Jordan-Nelson My company is developing an application for a very big client using Amplify and we are stuck since last year on this Amplify Reconfiguration thing only. Can anyone update me on this? Otherwise, we have to remove all AWS services and develop the application using other available services.
I'd like to describe our use case as well:
Our app currently supports two countries. For each country, we have a different Amplify project with a different list of users. So one user can have two different accounts, one for each country. And we allow the user to dynamically change its current country through a feature inside the app. When that happens, we log the user out so they can log in again on the selected country context. But to allow the user to log in on the selected country, we'd need to re-configure the amplify sdk with the configurations for the selected country amplify project, which is currently not possible.
(I'm also on version v0.6 because of some dependency conflicts, but we will probably migrate to v1 soon)
Please consider adding a runtime amplify reconfiguration. My customers have different API endpoints, and in React + Apollo I can dynamically set those urls Thanks!
Hello everyone, thank you for all the feedback on needing this feature. We have it on our radar, and we will investigate how to enable this moving forward. We will provide an update when we have a path forward.
Hello everyone, I have been interested in this function, especially my use case is to update the amplify configurations when any aws region presents a problem.
Right now the solution I see is to force the app to close and have the user start it again.
@abdallahshaban557 Any updates on this feature?
To clarify my request....I need to modify the GQL/Appsync Endpoints based on claims made in Cognito user attributes. Otherwise a Flutter/Amplify app can only connect with an initial configuration. My clients who use my app have unique APIs, hence the problem with a static amplifyconfiguration.dart file.
In an my React/Amplify app, I implement Apollo HttpLink within the client, which allows me to change the GQL URL at any time after the user has authenticated with Cognito. Thus, allowing me to modify user access based on their attributes post authentication.
https://www.apollographql.com/docs/react/api/link/apollo-link-http/
However, React does not provide an easy, maintainable development path for mobile/tablet (and even desktop) like flutter does.
Is there a roadmap to implement such a feature?
Hello @richwcahill - thank you for sharing that use case. We understand this request, and have plans to enable the re-configuration of Amplify Flutter to accomplish this. We do not have an exact timeline right now - but we will share it on this issue when we do!
My use case for the runtime configuration is to enable creating a silo multi-tenant app with one frontend. Which means that the app has a shared login page, then by using a prefix in the username I would be able to tell which backend environment the user belongs to and reconfigure the environment accordingly and grant the user access to his specific environment only.
My use-case is a multi-tenant application as well. As a workaround, I'm experimenting with restarting the Flutter engine using the restart plugin.
The plugin works by creating a new instance of the Flutter Engine. The entry point of the Dart VM is executed again, while the underlying platform specific application keeps running.
This allows me to reconfigure amplify without triggering an AmplifyAlreadyConfiguredException
, but I'm yet to test if it causes any runtime issues after the engine is restarted and configured for a different tenant. If Amplify.configure()
relies only on Dart code, this may work, since the Dart VM is restarted. If it calls and configures platform implementations, it will cause unexpected issues, because platform code is not restarted.
@Jordan-Nelson do you think this could work?
Updated Request
The ability to call
Amplify.configure()
multiple times with new config values, or to use different config values based on region or other condition.Original Request
I want to configure amplify once for Online including AmplifyDataStore Plugin and AmplifyAPI Plugin and second once for offline only AmplifyDataStore Plugin. How to remove configuration of amplify?