Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define firebase-remote-config parameters based on app version

I need to distribute some settings based on the app version e.g. if app version equals "4.0.1" then a else b. I found the possibility to define a condition named "version" but the documentation says it is bound to the package name of the app and not the version or version code.

see here https://firebase.google.com/docs/remote-config/parameters

I tried it though specifying the app version through a "version" condition but it does not work. Any ideas on this would be much appreciated.

like image 268
falkse Avatar asked Sep 07 '17 06:09

falkse


People also ask

How does Firebase remote configuration work?

What does Firebase Remote Configuration do? Firebase Remote Config is a cloud service that lets you change the behavior and appearance of your app without requiring users to download an app update. When using Remote Config, you create in-app default values that control the behavior and appearance of your app.

Which files contains configuration values for integrating Firebase backend with your mobile app?

You can download the Firebase config file or Firebase config object for each of your project's apps from the Firebase console's Project settings page. You need this config file or object to configure your app to use Firebase.

How do I get data from Firebase remote config?

Getting started Run the sample on an Android device or emulator. Change one or more parameter values in the Firebase Console (the value of welcome_message , welcome_message_caps , or both). Tap Fetch Remote Config in the app to fetch new parameter values and see the resulting change in the app.


1 Answers

The main problem is that Remote config's "Version" is the build number and not the actual version number.

The way I found around this is you can add a "User Property" in Firebase like "app_version". Then when the app launches add the following code:

let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
Analytics.setUserProperty(version, forName: "app_version")

You can then use this User Property in Remote Config as a condition and voila you can base some Remote Config value of of the version number. Note this will require the use of Firebase Analytics as well.

like image 172
SchmidtyApps Avatar answered Oct 06 '22 00:10

SchmidtyApps