I have an android app and using remote config.
I have this usecase and I want to send the app language change in that request. My app supports both English and Vietnam and the user can select their preferred language. I am just testing with changing to vietnam language.
However, in the request its always using my system device language. And as that is always set to English it always sends en-US.
In my firebase remote config console I have a field that has an Language condition for English and Vietnam. So based on that condition I can do something in the app.
Just a side question how does firebase know where to extract these properties and send them in the request?
The remote config allows key-value data to be sent to the frontend, but it needs to be actually used by the networking library.
The way the networking library picks up the language is similar to web browsers, by using Accept-Language Http Headers. Firebase Hosting also says it uses this method. Note that the "languageCode" of the device will automatically be sent to the backend, no additional work is needed to change it based on the devices settings. You would need to modify it if the user uses there phone in one language and wants to use the app in a different language.
Instruction to "Configure internationalization (i18n) rewrites" for Firebase Hosting are here. Here is an example in Flutter for localization with Firebase remote config.
In other Android contexts, this post explains how Accept-Language Http Headers may be used with OkHttp network requests. And this one for DefaultHttpClient
An example of how to change it in general on Android:
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(webServiceUrl);
request.addHeader("Accept-Language", "fr");
HttpResponse response = client.execute(request);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With