Firebase Remote Config

We have added a new extension which integrates with Firebase Remote Config. Remote Config allows you to push configuration data (strings, numbers and booleans) to your players without having to go through the app store. You can also integrate Remote Config with advanced A/B testing.

Learn more about how to use the extension here: Defold Firebase Remote Config documentation

18 Likes

This is great! Thank you! :grin::+1:

2 Likes

Awesome.
Tested it and it works great!

3 Likes

Happy to hear that it was useful to you!

1 Like

Is there any cache when fetching data?

I’m using the following code:

firebase.remoteconfig.init(function(self, event)
			if event == firebase.remoteconfig.CONFIG_ERROR then
				log("Firebase Remote Config error")
				return
			end
			if event == firebase.remoteconfig.CONFIG_FETCHED then
				print("Fetched")
			elseif event == firebase.remoteconfig.CONFIG_INITIALIZED then
				print("Initalzed")
				firebase.remoteconfig.fetch_and_activate()
			elseif event == firebase.remoteconfig.CONFIG_ACTIVATED then
				print("Activated")
				print_values()
			else
				print("Unknown event", event)
			end
		end)

Here is what happens:

  1. I go on Firebase dashboard and set the value my_param=1
  2. I open the app, the value, I get the remote config value my_param=1
  3. I go on Firebase dashboard and update the value my_param=2
  4. I open the app, the value, I get the remote config value my_param=1

It seems like the value is cached, do we any more info on this? Is it normal behaviour?

According to SO there’s a caching mechanism in Remote Config:

1 Like

OK thanks for the clarification. So it’s perfectly normal behaviour.
12 hours caching makes it a bit hard to debug though :sweat_smile:

It seems that with the Android SDK there is a method called setMinimumFetchIntervalInSeconds
that let the user define the caching time window.

I don’t see it in the C++ part of the Remote Config SDK, I guess it’s not present?

We need to expose this in the extension:

Yes, or this one?

Future<void> SetConfigSettings(ConfigSettings settings);

1 Like

Has anyone used this library for iOS? If yes, did you encounter any problem?

Calling get_string(key) doesn’t work properly on iOS.

I have this value on my remote config dashboard

and here is my code

function firebase_init(self)
	if firebase then
		local ok, err = firebase.init()
		if  ok then
			firebase.analytics.init(function(self, ok, err)
				if not ok then
					print(err)
					return
				end
			end)
			firebase.remoteconfig.init(function(self, event)
				if event == firebase.remoteconfig.CONFIG_ERROR then
					print("firebase.remoteconfig.CONFIG_ERROR")

				elseif event == firebase.remoteconfig.CONFIG_FETCHED then
					print("firebase.remoteconfig.CONFIG_FETCHED")
					firebase.remoteconfig.activate()
					

				elseif event == firebase.remoteconfig.CONFIG_INITIALIZED then
					print("firebase.remoteconfig.CONFIG_INITIALIZED")
					firebase.remoteconfig.fetch()

				elseif event == firebase.remoteconfig.CONFIG_DEFAULTS_SET then
					print("firebase.remoteconfig.CONFIG_DEFAULTS_SET")

				elseif event == firebase.remoteconfig.CONFIG_ACTIVATED then
					print("firebase config activated")
					local names = { "test_two", "Test44"}
					for i,v in ipairs(names) do
						print("firebase fetchin parameter " .. v)
						local s = firebase.remoteconfig.get_string(v) 
						if s then
							print("firebase result: "..s)
						end
						
						
					end

				else
					print("Firebase remote config other message")
				end
			end)
			print("firebase.remoteconfig init launched")
		else
			print("error initiating firebase")
		end
	else
		print("NO firebase")
	end
end 

It prints null.

Anyone has this issue?

After some investigation, I noticed a very strange behaviour.
If the value I put in firebase dashboard is longer than 22 characters, then the client can’t read it.
Anything shorter than 22 characters works. Anyone having a similar issue?

Interesting and very strange. You could try and update to the latest version of the Firebase SDK according to instructions in the extension.

Note: for iOS, using get_data instead of get_string seems to resolve the issue.

Really weird. The implementation for both of these are very simple. The problem must be somewhere inside the RemoteConfig library itself. An update may solve it, but it’s good that you found a workaround!

Just putting it out there for anyone havin a similar issue:

  • When I put a string value with more than 22 characters, get_string returns empty (!)
  • Instead, I use get_data, but when I do, I sometimes get extra characters:
    I should be getting the string {"key":"value_1"} but I get {"key":"value_1"}Cab or {"key":"value_1"}dee (no idea where those characters come from).

What I do is that I truncate all the characters after the last }

local index_last_bracket = string.match(my_string, '^.*()}')
local len_str = string.len(my_string)
if index_last_bracket < len_str then
   my_string = string.sub(d, 1, index_last_bracket)
end

It’s all really weird but that’s the best I could do.

Created a ticket to track this: https://github.com/defold/extension-firebase-remoteconfig/issues/2

Fixed issue and released a new version: https://github.com/defold/extension-firebase-remoteconfig/releases/tag/1.0.3

1 Like

Great job, thanks!

I’d like to expose the ‘Firebase installation auth token’ to allow validation of A/B tests as described here
Is that best added to extension-firebase, as the auth token is part of the core of Firebase (but will mean adding the Installations library) or to the remote config extension?