5
votes

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
I have the same problem here, did you find any solution? I have try regex [1-1].[8-9][2-9].[0-9] and also adding the app version as string ("1.82.0") and as numbers (1.82.0). Nothing works. Is there any configuration I may be missing? - Lui Cruz

2 Answers

4
votes

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.

1
votes

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.