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

3k Views Asked by At

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.

2

There are 2 best solutions below

1
On BEST ANSWER

Creating a condition, which targets an app version via regular expression appears to be the only solution in this case.

For my app I use the following configuration:

Targeting version via regexp

Here, users who have versions 1.8.* and below receive an alternate version of a backend configuration parameter.

If you need to target only a specific version of the app, then a regular expression is not really necessary, so the approach that you took should work.

Alternatively, you can have far more control if you create a user audience based on app version, and then target the audience.

0
On

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.