How to access different server at the run time of mobile app?

73 views Asked by At

I've a Flutter mobile app. My app have 4 different servers each have unique purpose

Test Development Staging Production

My app have a hidden button on the login screen which won't visible to the end user. So when I developing the app I'm using development server.

The app pointing to the production server at default. When user install it from appstore or playstore they can use without changing the server.

If a tester want to test the app then he have to get the app and Need to change the server url to Test server by accessing the hidden page to change the server. Like wise if we give the app to client they have to change the server to staging...

Now my question is Is this a right way to manage the deployment process?

Having a hidden button on the production app to change the server is safe ?

How the industry is managing this process ?

2

There are 2 answers

2
Ozan Taskiran On

You should deploy different versions of your app with flavors. With flavors you can create environments (dev, staging, prod, etc.).

See the offical Flutter docs how to setup flavors, you have to do it on the native side.

https://docs.flutter.dev/deployment/flavors?gclid=Cj0KCQiAmNeqBhD4ARIsADsYfTejoSNHLEi7TUmd-WIrO03asW-YEyedHwB4_fvCwtB4VNVt66Dn0hoaArADEALw_wcB&gclsrc=aw.ds

0
Kayson On

otherwise you can also use an entry endpoint for the users and manage a configuration preload in your app depending on the connected user info. This way the same application will be able to interact with the prod, dev, or staging server following the config delivered remotely by the admin.