Table of Contents:
The Firebase component communicates with a Web service to store and retrieve information. The component has methods to store a value under a tag and to retrieve the value associated with the tag. It also possesses a listener to fire events when stored values are changed.
- Getter for the DeveloperBucket.
- Getter for the FirebaseToken.
- Specifies the URL for the Firebase.
The default value is currently my private Firebase URL, but this will eventually changed once the App Inventor Candle plan is activated.
- If true, variables will retain their values when off-line and the App exits. Values will be uploaded to Firebase the next time the App is run while connected to the network. This is useful for applications which will gather data while not connected to the network. Note: AppendValue and RemoveFirst will not work correctly when off-line, they require a network connection.
Note: If you set Persist on any Firebase component, on any screen, it makes all Firebase components on all screens persistent. This is a limitation of the low level Firebase library. Also be aware that if you want to set persist to true, you should do so before connecting the Companion for incremental development.
- Getter for the ProjectBucket.
- Indicates that the data in the Firebase has changed. Launches an event with the tag and value that have been updated.
- Indicates that the communication with the Firebase signaled an error.
- Event triggered by the “RemoveFirst” function. The argument “value” is the object that was the first in the list, and which is now removed.
- Indicates that a GetValue request has succeeded.
- Event triggered when we have received the list of known tags. Used with the “GetTagList” Function.
- Append a value to the end of a list atomically. If two devices use this function simultaneously, both will be appended and no data lost.
- Asks Firebase to forget (delete or set to “null”) a given tag.
- Get the list of tags for this application. When complete a “TagList” event will be triggered with the list of known tags.
- GetValue asks Firebase to get the value stored under the given tag. It will pass valueIfTagNotThere to GotValue if there is no value stored under the tag.
- Return the first element of a list and atomically remove it. If two devices use this function simultaneously, one will get the first element and the the other will get the second element, or an error if there is no available element. When the element is available, the “FirstRemoved” event will be triggered.
- Asks Firebase to store the given value under the given tag.
- Unauthenticate from Firebase.
Firebase keeps track of credentials in a cache in shared_prefs It will re-use these credentials as long as they are valid. Given That we retrieve a FirebaseToken with a version long life, this will effectively be forever. Shared_prefs survive an application update and depending on how backup is configured on a device, it might survive an application removal and reinstallation.
Normally this is not a problem, however if we change the credentials used, for example the App author is switching from one Firebase account to another, or invalided their firebase.secret, this cached credential is invalid, but will continue to be used, which results in errors.
This function permits us to unauthenticate, which tosses the cached credentials. The next time authentication is needed we will use our current FirebaseToken and get fresh credentials.