This is a wrapper of Firebase RemoteConfig library for B4i. You can find the B4A version here. I made this for @Jack Cole and he gave me permission to post this in forum to help other users.
iFirebaseRemoteConfig
Wrapper: @Biswajit
Version: 1.1
Installation:
Click Here to Download
iFirebaseRemoteConfig
Wrapper: @Biswajit
Version: 1.1
- FirebaseRemoteConfig
- Events:
- ActivatedWithCompletion (error As String)
- FetchedAndActivatedWithCompletion (status As Int, error As String)
- FetchedWithCompletion (status As Int, error As String)
- FetchedWithExpirationDuration (status As Int, error As String)
- InitializationFailed (error As String)
- Initialized
- Fields:
- FIRRemoteConfigError_InternalError As Int
- FIRRemoteConfigError_Throttled As Int
- FIRRemoteConfigError_Unknown As Int
- FIRRemoteConfigFetchAndActivateStatus_Error As Int
- FIRRemoteConfigFetchAndActivateStatus_SuccessFetchedFromRemote As Int
- FIRRemoteConfigFetchAndActivateStatus_SuccessUsingPreFetchedData As Int
- FIRRemoteConfigFetchStatus_Failure As Int
- FIRRemoteConfigFetchStatus_NoFetchYet As Int
- FIRRemoteConfigFetchStatus_Success As Int
- FIRRemoteConfigFetchStatus_Throttled As Int
- FIRRemoteConfigSource_Default As Int
- FIRRemoteConfigSource_Remote As Int
- FIRRemoteConfigSource_Static As Int
- Functions:
- ActivateWithCompletionHandler
Applies Fetched Config data to the Active Config, causing updates to the behavior and
appearance of the app to take effect (depending on how config data is used in the app).
This will raise <b>Eventname_ActivatedWithCompletion</b> event.
Error message will be empty if activation succeeded. - AllKeysFromSource (source As Int) As List
Gets all the parameter keys from a given source.
The source can be any constant value from FIRRemoteConfigSource. - ConfigValueForKey (key As String) As FirebaseRemoteConfigValue
Gets the config value. - ConfigValueForKeySource (key As String, source As Int) As FirebaseRemoteConfigValue
Gets the config value of a given source. The source can be any constant value from FIRRemoteConfigSource. - DefaultValueForKey (key As String) As FirebaseRemoteConfigValue
Returns the default value of a given key from the default config. - EnsureInitializedWithCompletionHandler
Ensures initialization is complete and clients can begin querying for Remote Config values.
This will raise <b>Eventname_Initialized</b> event if initialization succeeded. Else <b>Eventname_InitializationFailed</b>. - FetchAndActivateWithCompletionHandler
Fetches Remote Config data and if successful, activates fetched data. Optional completion handler callback
is invoked after the attempted activation of data, if the fetch call succeeded.
This will raise <b>Eventname_FetchedAndActivatedWithCompletion</b> event.
Error message will be empty if fetching succeeded.
Status can be any constant value from FIRRemoteConfigFetchAndActivateStatus. - FetchWithCompletionHandler
Fetches Remote Config data with a callback.
This will raise <b>Eventname_FetchedWithCompletion</b> event.
Error message will be empty if fetching succeeded.
Status can be any constant value from FIRRemoteConfigFetchStatus. - FetchWithExpirationDuration (expirationDuration As Long)
Fetches Remote Config data and sets a duration that specifies how long config data lasts.
Override the (default or optionally set minimumFetchInterval property in FIRRemoteConfigSettings) minimumFetchInterval
for only the current request, in seconds. Setting a value of 0 seconds will force a fetch to the backend.
This will raise <b>Eventname_FetchedWithExpirationDuration</b> event.
Error message will be empty if fetching succeeded.
Status can be any constant value from FIRRemoteConfigFetchStatus. - Initialize (eventname As String, callback As Object)
Initializes the library inside the Application_Start function.
<b>You should initialize FirebaseAnalytics before initializing this library.</b> - IsInitialized As Boolean
Tests whether the object has been initialized. - KeysWithPrefix (prefix As String) As List
Returns the set of parameter keys that start with the given prefix, from the default namespace in the active config.
If prefix is nil or empty, returns all the keys. - ObjectForKeyedSubscript (key As String) As FirebaseRemoteConfigValue
Gets the config value by using object subscripting syntax.
- ActivateWithCompletionHandler
- Properties:
- ConfigSettings As FirebaseRemoteConfigSettings
Set custom config settings. - Defaults As Map
Sets config defaults for parameter keys and values in the default namespace config. - LastFetchStatus As Int [read only]
Last fetch status. The status can be any constant value from FIRRemoteConfigFetchStatus. - LastFetchTime As Long [read only]
Last successful fetch completion time.
- ConfigSettings As FirebaseRemoteConfigSettings
- Events:
- FirebaseRemoteConfigSettings
Firebase Remote Config settings- Functions:
- Initialize
Initialize Firebase Remote Config settings. - isDeveloperModeEnabled As Boolean
Indicates whether Developer Mode is enabled. - IsInitialized As Boolean
Tests whether the object has been initialized.
- Initialize
- Properties:
- FetchTimeout As Long
Indicates the default value in seconds to abandon a pending fetch request made to the backend. This value is set for outgoing requests as the timeoutIntervalForRequest as well as the timeoutIntervalForResource on the NSURLSession’s configuration. - MinimumFetchInterval As Long
Indicates the default value in seconds to set for the minimum interval that needs to elapse before a fetch request can again be made to the Remote Config backend. After a fetch request to the backend has succeeded, no additional fetch requests to the backend will be allowed until the minimum fetch interval expires.
<b>Note:</b> you can override this default on a per-fetch request basis using RemoteConfig.fetchWithExpirationDuration. For E.g. setting the expiration duration to 0 in the fetch request will override the minimumFetchInterval and allow the request to the backend.
- FetchTimeout As Long
- Functions:
- FirebaseRemoteConfigValue
This class provides a wrapper for Remote Config parameter values, with methods to get parameter values as different data types.- Functions:
- Initialize (value As Object)
- IsInitialized As Boolean
Tests whether the object has been initialized.
- Properties:
- BoolValue As Boolean [read only]
Gets the value as a boolean. - DataValue As Byte() [read only]
Gets the value as a NSData object. - DoubleValue As Double [read only]
Gets the value as a double value. - IntValue As Int [read only]
Gets the value as an int value. - JSONValueAsList As List [read only]
Gets a foundation object (NSArray / List) by parsing the value as JSON.
This method uses NSJSONSerialization’s JSONObjectWithData method with an options value of 0. - JSONValueAsMap As Map [read only]
Gets a foundation object (NSDictionary / Map) by parsing the value as JSON.
This method uses NSJSONSerialization’s JSONObjectWithData method with an options value of 0. - LongValue As Long [read only]
Gets the value as a long value. - Source As Int [read only]
Identifies the source of the fetched value. One of the FIRRemoteConfigSource constant. - StringValue As String [read only]
Gets the value as a string.
- BoolValue As Boolean [read only]
- Functions:
Installation:
- Download the latest libraries from here.
- Download the attached ZIP file.
- Copy the .framework, .a and .h file to the local build server's Libs folder.
- Then copy the XML file to the B4i library folder.
- Create a new B4i project.
- Follow firebase integration tutorial from here
- After initializing the Firebase Analytic library initialize this RemoteConfig library.
- Please check the RemoteConfig throttling documentation from here.
- V1.1 - Fixed compilation issue with the newer firebase framework.
Click Here to Download
Last edited: