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.
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:
I go on Firebase dashboard and set the value my_param=1
I open the app, the value, I get the remote config value my_param=1
I go on Firebase dashboard and update the value my_param=2
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?
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
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?
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.
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?