Announcement

Collapse
No announcement yet.

Realtime Database for all platforms - Firebase

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Awesome - Really looking forward to this!

    Comment


      #17
      I'm SUPER interested in this plugin, sounds like EXACTLY what I'm looking for.

      Can I use it to seamlessly sync UFS (the native unreal game file save format) across network connected Windows, Android and IOS devices?

      Comment


        #18
        Originally posted by WhiteNorthStar View Post
        I'm SUPER interested in this plugin, sounds like EXACTLY what I'm looking for.

        Can I use it to seamlessly sync UFS (the native unreal game file save format) across network connected Windows, Android and IOS devices?
        Hi WhiteNorthStar,

        I'm very happy that you are interested in this plugin!

        This is a database, not a file storage. So you will be able to map properties from Save File to Database Fields and sync
        Realtime Database Firebase | Ultimate Mobile Kit Firebase | Extended Facebook | Universal Mobile Ads | Google Analytics

        Comment


          #19
          Looking forward to the release, I've used Firebase in the past and it would be perfect for an upcoming project.

          Comment


            #20
            Hi Is this plugin available ? where can I get it ? thanks !

            Comment


              #21
              Originally posted by hamuQ View Post
              Hi Is this plugin available ? where can I get it ? thanks !
              Not yet. iOS and Android versions are done and tested in 100%. I'm thinking about releasing mobile version as Early Access.
              Realtime Database Firebase | Ultimate Mobile Kit Firebase | Extended Facebook | Universal Mobile Ads | Google Analytics

              Comment


                #22



                Database Core

                Initialization

                Before making any call to the Firebase Realtime Database, first, you should execute the Firebase Database Init function. If the result is a fail, study logs to find out what causes an issue.



                Permissions

                The Realtime Database provides a declarative rules language that allows you to define how your data should be structured, how it should be indexed, and when your data can be read from and written to. By default, read and write access to your database is restricted so only authenticated users can read or write data. To get started without setting up Authentication, you can configure your rules for public access. This does make your database open to anyone, even people not using your game, so be sure to restrict your database again when you set up authentication. If you do not want to use public access you can add Firebase Authentication to your app to control access to the database.

                Go Online/Offline



                You can manipulate whether your game is connected to the Firebase Realtime Database or not.
                • Go Online – Resumes the connection to the Firebase Realtime Database backend after a previous Go Offline call.
                • Go Offline – Shuts down the connection to the Firebase Realtime Database backend until Go Online is called.


                Purge Outstanding Writes



                This function purges all pending writes to the Firebase Realtime Database server. 



                Database Reference

                Database Reference represents a particular location in your Database and can be used for reading or writing data to that Database location. This class is the starting point for all Database operations. After you've initialized it with a URL, you can use it to read data, write data, and to create new Database Reference instances.

                Get Reference



                You can get Database Reference using one of three available functions:
                • Firebase Database Get Reference – get a Database Reference to the root of the database.
                • Firebase Database Get Reference From Path – get a Database Reference for the specified path.
                • Firebase Database Get Reference From URL – get a Database Reference for the provided URL, which must belong to the database URL this instance is already connected to.


                Tree manipulating



                For more flexible tree manipulating you can use the following functions instead of paths or URLs:
                • Child – gets a reference to a location relative to this one.
                • Get Parent – gets the parent of this location, or get this location again if Is Root.
                • Get Root – gets the root of the database.
                • Is Root – returns true if this reference refers to the root of the database.
                • Key – gets the string key of this database location.
                • Url – gets the absolute URL of this reference.


                The above example is an equivalent of path /users/eclarke and URL https://fir-gamedna.firebaseio.com/users/eclarke.
                Realtime Database Firebase | Ultimate Mobile Kit Firebase | Extended Facebook | Universal Mobile Ads | Google Analytics

                Comment


                  #23
                  This is a joke right? Where did this functionality go in the Ultimate Mobile Kit? Pulling the text and advertisement for it from the self pages doesn't mean it wasn't there when I bought the pack. Are we getting a rebate for the false advertisement?
                  Do Not Argue Toxic Game
                  Balloony PoP get it on Google Play
                  Fishy Blub Blub
                  get it on Google Play

                  Comment


                    #24
                    Originally posted by KillerSneak View Post
                    This is a joke right? Where did this functionality go in the Ultimate Mobile Kit? Pulling the text and advertisement for it from the self pages doesn't mean it wasn't there when I bought the pack. Are we getting a rebate for the false advertisement?
                    Hi KillerSneak,

                    Realtime Database never hasn't been advertised as part of Ultimate Mobile Kit. We have splitted Firebase functionality to separate plugins since start of development. Ultimate Mobile Kit - features for mobile only and Realtime Database - features for all platforms. For confirmation you can check start date of forum threads for Ultimate Mobile Kit (03-05-2017, 06:15 PM) and Realtime Database (03-05-2017, 08:40 PM). It was announced at the same day. "Realtime Database" words have never been used on the advertisement images of Ultimate Mobile Kit. We thought that it was clear. We announced two plugins at the same time to eliminate doubts. We are very sorry that it was still misunderstood Check your PM box, we sent you more details.
                    Realtime Database Firebase | Ultimate Mobile Kit Firebase | Extended Facebook | Universal Mobile Ads | Google Analytics

                    Comment


                      #25
                      Variants

                      Firebase Variant is a main data type for Firebase platform and is used instead of multiple standard types such as: integer, float, string, bool, arrays, maps, etc.

                      Construct Variant

                      Construct Variant functions create and return a new Variant from provided data type.
                      • Construct From Bool – return a Variant from a boolean.
                      • Construct From Float – return a Variant from a floating point number.
                      • Construct From Integer – return a Variant from an integer number.
                      • Construct From String – return a Variant from a string.
                      • Construct Empty String – get an empty string variant.
                      • Construct Empty Array – get a Variant containing an empty array.
                      • Construct One – get a Variant of integer value 1.
                      • Construct Zero – get a Variant of integer value 0.
                      • Construct Zero Point Zero – get a Variant of double value 0.0.
                      • Construct One Point Zero – get a Variant of double value 1.0.
                      • Construct True Object – get a Variant of bool value true.
                      • Construct False Object – get a Variant of bool value false.
                      • Construct Empty Map – get a Variant containing an empty map.
                      • Construct Null – get a Variant of type Null.






                      Convert Variant

                      You can Convert Variant from one data type to another.
                      • As Bool – get the current Variant converted into a boolean.
                      • As Float – get the current Variant converted into a floating-point number.
                      • As Integer – get the current Variant converted into an integer.
                      • As String – get the current Variant converted into a string.






                      Check Type

                      You can get and check current Variant type using below functions:
                      • Type – get the current type contained in this Variant.
                      • Is Array – get whether this Variant contains a vector.
                      • Is Map – get whether this Variant contains a map.
                      • Is Null – get whether this Variant is currently null.
                      • Is Static String – get whether this Variant contains a static string.
                      • Is Mutable String – get whether this Variant contains a mutable string.
                      • Is String – get whether this Variant contains a string.
                      • Is Integer – get whether this Variant contains an integer.
                      • Is Float – get whether this Variant contains a float.
                      • Is Numeric – get whether this Variant contains a numeric type, integer or float.
                      • Is Bool – get whether this Variant contains a bool.
                      • Is Fundamental Type – get whether this Variant contains a fundamental type: null, integer, double, bool, or one of the two string types.
                      • Is Container Type – get whether this Variant contains a container type: array or map.






                      Get Value
                      • Bool Value – accessor for a Variant containing a bool.
                      • Float Value – accessor for a Variant containing a float.
                      • Integer Value – accessor for a Variant containing an integer.
                      • String Value – accessor for a Variant containing a string.




                      • Array Value – accessor for a Variant containing an array of Variant data.



                      • Map Value – accessor for a Variant containing a map of Variant data.





                      Set Value
                      • Set Bool Value – sets the Variant to the given boolean value.
                      • Set Float Value – sets the Variant to a double-precision floating point value.
                      • Set String Value – sets the Variant to a copy of the given string.
                      • Set Integer Value – sets the Variant to an integer value.




                      • Set Array – sets the Variant to a copy of the given array.



                      • Set Map – sets the Variant to a copy of the given map.

                      Realtime Database Firebase | Ultimate Mobile Kit Firebase | Extended Facebook | Universal Mobile Ads | Google Analytics

                      Comment


                        #26
                        Read Data

                        Retrieve Data

                        You can use the Get Value method to read a static snapshot of the contents at a given path once. The task result will contain a snapshot containing all data at that location, including child data. If there is no data, the snapshot returned is null.



                        When query is completed, you can call Value on downloaded Data Snapshot:



                        You can manipulate database tree in downloaded Data Snapshot using child nodes:
                        • Has Child – does this Data Snapshot contain data at a particular location?
                        • Child – get a Data Snapshot for the location at the specified relative path.
                        • Has Children – does this Data Snapshot contain any children at all?
                        • Children – get all the immediate children of this location.
                        • Children Count – get the number of children of this location.
                        • Exists – returns true if the data is non-empty.
                        • Key – get the key name of the source location of this snapshot.
                        • Priority – get the priority of the data contained in this snapshot.






                        Sorting Data

                        To retrieve sorted data, start by specifying one of the order-by methods to determine how results are ordered:
                        • Order By Child – order results by the value of a specified child key.
                        • Order By Key – order results by child keys.
                        • Order By Value – order results by child values.
                        • Order By Priority – order results by child priorities.




                        The call to the Order By Child method specifies the child key to order the results by. In this case, results are sorted by the value of the price value in each child.
                        You can only use one order-by method at a time. Calling an order-by method multiple times in the same query throws an error.



                        Filtering Data

                        To filter data, you can combine any of the limit or range methods with an order-by method when constructing a query.
                        • Limit To First – sets the maximum number of items to return from the beginning of the ordered list of results.
                        • Limit To Last – sets the maximum number of items to return from the end of the ordered list of results.
                        • Start At – return items greater than or equal to the specified key or value depending on the order-by method chosen.
                        • End At – return items less than or equal to the specified key or value depending on the order-by method chosen.
                        • Equal To – return items equal to the specified key or value depending on the order-by method chosen.


                        Unlike the order-by methods, you can combine multiple limit or range functions. For example, you can combine the Start At and End At methods to limit the results to a specified range of values.

                        Even when there is only a single match for the query, the snapshot is still a list; it just contains a single item.





                        How query data is ordered

                        Order By Child

                        When using Order By Child, data that contains the specified child key is ordered as follows:
                        • Children with a null value for the specified child key come first.
                        • Children with a value of false for the specified child key come next. If multiple children have a value of false, they are sorted lexicographically by key.
                        • Children with a value of true for the specified child key come next. If multiple children have a value of true, they are sorted lexicographically by key.
                        • Children with a numeric value come next, sorted in ascending order. If multiple children have the same numerical value for the specified child node, they are sorted by key.
                        • Strings come after numbers and are sorted lexicographically in ascending order. If multiple children have the same value for the specified child node, they are ordered lexicographically by key.
                        • Objects come last and are sorted lexicographically by key in ascending order.


                        Order By Key

                        When using Order By Key to sort your data, data is returned in ascending order by key.
                        • Children with a key that can be parsed as a 32-bit integer come first, sorted in ascending order.
                        • Children with a string value as their key come next, sorted lexicographically in ascending order.


                        Order By Value

                        When using Order By Value, children are ordered by their value. The ordering criteria are the same as in Order By Child, except the value of the node is used instead of the value of a specified child key.




                        Save Data

                        Basic write operations

                        For basic write operations, you can use Set Value to save data to a specified reference, replacing any existing data at that path. You can use this method to pass types accepted by JSON through a Variant type which supports:
                        • Null (this deletes the data)
                        • Integers (64-bit)
                        • Floating point numbers
                        • Booleans
                        • Strings
                        • Arrays of Variants
                        • Maps of strings to Variants


                        Using Set Value in this way overwrites data at the specified location, including any child nodes. However, you can still update a child without rewriting the entire object:



                        You can set priority of the database field which controls its sort order relative to its siblings.

                        In Firebase, children are sorted in the following order:
                        • First, children with no priority.
                        • Then, children with numerical priority, sorted numerically in ascending order.
                        • Then, remaining children, sorted lexicographically in ascending order of their text priority.


                        Children with the same priority (including no priority) are sorted by key: A. First, children with keys that can be parsed as 32-bit integers, sorted in ascending numerical order of their keys. B. Then, remaining children, sorted in ascending lexicographical order of their keys.



                        It's possible to set value and priority in one function call:





                        Append to a list of data

                        Use the Push Child method to append data to a list in multiuser applications. The Push Child method generates a unique key every time a new child is added to the specified Firebase reference. By using these auto-generated keys for each new element in the list, several clients can add children to the same location at the same time without write conflicts. The unique key generated by Push Child is based on a timestamp, so list items are automatically ordered chronologically.

                        You can use the reference to the new data returned by the Push Child method to get the value of the child's auto-generated key or set data for the child. Calling Get Key on a Push Child reference returns the value of the auto-generated key.





                        Update specific fields

                        To simultaneously write to specific children of a node without overwriting other child nodes, use the Update Children method.

                        When calling Update Children, you can update lower-level child values by specifying a path for the key. If data is stored in multiple locations to scale better, you can update all instances of that data using data fan-out. Simultaneous updates made this way are atomic: either all updates succeed or all updates fail.





                        Delete data

                        The simplest way to delete data is to call Remove Value on a reference to the location of that data.

                        You can also delete by specifying a null Variant as the value for another write operation such as Set Value or Update Children. You can use this technique with Update Children to delete multiple children in a single API call.





                        Transactions

                        When working with data that could be corrupted by concurrent modifications, such as incremental counters, you can use a transaction operation. You give this operation the Do Transaction function. This update function takes the current state of the data as an argument and returns the new desired state you would like to write. If another client writes to the location before your new value is successfully written, your update function is called again with the new current value, and the write is retried. If the transaction is rejected, the server returns the current value to the client, which runs the transaction again with the updated value. This repeats until the transaction is accepted or too many attempts have been made.

                        Note 1: Because Run Transaction is called multiple times, it must be able to handle null data. Even if there is existing data in your remote database, it may not be locally cached when the transaction function is run, resulting in null for the initial value.

                        Note 2: Only one transaction can be executed at the same time.





                        How to make the Do Transaction function?
                        1. Create a new Blueprint Class inherited from Firebase Database Reference Do Transaction Proxy.
                        2. Override the Do Transaction function and make your own logic.



                        Do Transaction is your own transaction handler, which the Firebase Realtime Database library may call multiple times to apply changes to the data, and should return success or failure depending on whether it succeeds.

                        This function will be called, possibly multiple times, with the current data at this location. The function is responsible for inspecting that data and modifying it as desired, then returning a Transaction Result specifying either that the Mutable Data was modified to a desired new state, or that the transaction should be aborted. Whenever this function is called, the Mutable Data passed in must be modified from scratch.

                        Since this function may be called repeatedly for the same transaction, be extremely careful of any side effects that may be triggered by this function. In addition, this function is called from within the Firebase Realtime Database library's run loop, so care is also required when accessing data that may be in use by other threads in your application.
                        Realtime Database Firebase | Ultimate Mobile Kit Firebase | Extended Facebook | Universal Mobile Ads | Google Analytics

                        Comment


                          #27
                          Realtime Features

                          You can add listeners to subscribe on changes in realtime to data in specified location at the database.

                          Value Listener

                          You can use the On Value Changed callbacks to subscribe to changes to the contents at a given path. This callback is triggered once when the listener is attached and again every time the data, including children, changes. The callback is passed a snapshot containing all data at that location, including child data. If there is no data, the snapshot returned is null. A read can be canceled (On Cancelled) if the client doesn't have permission to read from a Firebase database location.



                          Important: The On Value Changed event is called every time data is changed at the specified database reference, including changes to children. To limit the size of your snapshots, attach only at the highest level needed for watching changes. For example, attaching a listener to the root of your database is not recommended.

                          Child Listener

                          Child events are triggered in response to specific operations that happen to the children of a node from an operation such as a new child added through the Push Child method or a child being updated through the Update Children method. Each of these together can be useful for listening to changes to a specific node in a database. For example, a game might use these methods together to monitor activity in the comments of a game session.


                          • On Child Added – the callback is typically used to retrieve a list of items in a Firebase database. The On Child Added callback is called once for each existing child and then again every time a new child is added to the specified path. The listener is passed a snapshot containing the new child's data.
                          • On Child Changed – the callback is called any time a child node is modified. This includes any modifications to descendants of the child node. It is typically used in conjunction with the On Child Added and On Child Removed calls to respond to changes to a list of items. The snapshot passed to the listener contains the updated data for the child.
                          • On Child Removed – the callback is triggered when an immediate child is removed. It is typically used in conjunction with the On Child Added and On Child Changed callbacks. The snapshot passed to the callback contains the data for the removed child.
                          • On Child Moved – the callback is triggered whenever the On Child Changed call is raised by an update that causes reordering of the child. It is used with data that is ordered with Order By Child or Order By Value.


                          Remove Listeners

                          You can remove attached listeners simply calling Remove Child Listener or Remove Value Listener.

                          Realtime Database Firebase | Ultimate Mobile Kit Firebase | Extended Facebook | Universal Mobile Ads | Google Analytics

                          Comment


                            #28
                            Offline Features

                            Firebase applications work even if your game temporarily loses its network connection. In addition, Firebase provides tools for persisting data locally, managing presence, and handling latency.

                            Persistence Behavior

                            Firebase apps automatically handle temporary network interruptions. Cached data is available while offline and Firebase resends any writes when network connectivity is restored.

                            When you enable disk persistence, your app writes the data locally to the device so your app can maintain state while offline, even if the user or operating system restarts the app.

                            You can enable disk persistence by ticking Enable Disk Persistence option in Plugin Settings:



                            By enabling persistence, any data that the Firebase Realtime Database client would sync while online persists to disk and is available offline, even when the user or operating system restarts the game. This means your game works as it would online by using the local data stored in the cache. Listener callbacks will continue to fire for local updates.

                            The Firebase Realtime Database client automatically keeps a queue of all write operations that are performed while your game is offline. When persistence is enabled, this queue is also persisted to disk so all your writes are available when the user or operating system restarts the game. When the game regains connectivity, all the operations are sent to the Firebase Realtime Database server.

                            If your game uses Firebase Authentication, the Firebase Realtime Database client persists the user's authentication token across game restarts. If the auth token expires while your game is offline, the client pauses write operations until your game re-authenticates the user, otherwise the write operations might fail due to security rules.


                            Keeping Data Fresh

                            The Firebase Realtime Database synchronizes and stores a local copy of the data for active listeners. In addition, you can keep specific locations in sync.



                            The Firebase Realtime Database client automatically downloads the data at these locations and keeps it in sync even if the reference has no active listeners. You can turn synchronization back off with the following function.



                            By default, 10MB of previously synced data is cached. This should be enough for most applications. If the cache outgrows its configured size, the Firebase Realtime Database purges data that has been used least recently. The data that is kept in sync is not purged from the cache.

                            Querying Data Offline

                            The Firebase Realtime Database stores data returned from a query for use when offline. For queries constructed while offline, the Firebase Realtime Database continues to work for previously loaded data. If the requested data hasn't loaded, the Firebase Realtime Database loads data from the local cache. When network connectivity is available again, the data loads and will reflect the query.




                            Save Data Offline

                            If a client loses its network connection, your game will continue functioning correctly.
                            Every client connected to a Firebase database maintains its own internal version of any active data. When data is written, it's written to this local version first. The Firebase client then synchronizes that data with the remote database servers and with other clients on a "best-effort" basis.

                            As a result, all writes to the database trigger local events immediately, before any data is written to the server. This means your app remains responsive regardless of network latency or connectivity.

                            Once connectivity is reestablished, your game receives the appropriate set of events so that the client syncs with the current server state, without having to write any custom code.

                            Handling Transactions Offline

                            Any transactions that are performed while the game is offline, are queued. Once the game regains network connectivity, the transactions are sent to the Realtime Database server.

                            Even with persistence enabled, transactions are not persisted across game restarts. So, you cannot rely on transactions done offline being committed to your Firebase Realtime Database. To provide the best user experience, your game should show that a transaction has not been saved into your Firebase Realtime Database yet, or make sure your game remembers them manually and executes them again after a game restart.


                            Managing Presence

                            In realtime games it is often useful to detect when clients connect and disconnect. For example, you may want to mark a user as 'offline' when their client disconnects.

                            Firebase Database clients provide simple primitives that you can use to write to the database when a client disconnects from the Firebase Database servers. These updates occur whether the client disconnects cleanly or not, so you can rely on them to clean up data even if a connection is dropped or a client crashes. All write operations, including setting, updating, and removing, can be performed upon a disconnection.



                            When you establish an On Disconnect operation, the operation lives on the Firebase Realtime Database server. The server checks security to make sure the user can perform the write event requested, and informs your game if it is invalid. The server then monitors the connection. If at any point the connection times out, or is actively closed by the Realtime Database client, the server checks security a second time (to make sure the operation is still valid) and then invokes the event.

                            An On Disconnect event can also be canceled by Cancel:



                            You can bind the following functions to On Disconnect:
                            • Set Value – set the value of the data at the current location when the client disconnects.
                            • Set Value And Priority – set the value and priority of the data at the current location when the client disconnects.
                            • Remove Value – remove the value at the current location when the client disconnects.
                            • Update Children – updates the specified child keys to the given values when the client disconnects.


                            Detecting Connection State

                            For many presence-related features, it is useful for your game to know when it is online or offline. Firebase Realtime Database provides a special location at /.info/connected which is updated every time the Firebase Realtime Database client's connection state changes. Here is an example:



                            /.info/connected is a boolean value which is not synchronized between Realtime Database clients because the value is dependent on the state of the client. In other words, if one client reads /.info/connected as false, this is no guarantee that a separate client will also read false.

                            On Android, Firebase automatically manages connection state to reduce bandwidth and battery usage. When a client has no active listeners, no pending write or On Disconnect operations, and is not explicitly disconnected by the Go Offline method, Firebase closes the connection after 60 seconds of inactivity.
                            Last edited by gameDNA studio; 12-11-2017, 07:08 PM.
                            Realtime Database Firebase | Ultimate Mobile Kit Firebase | Extended Facebook | Universal Mobile Ads | Google Analytics

                            Comment


                              #29
                              Is the early access version compatible with desktop game projects or is it mobile games only?

                              Comment


                                #30
                                Originally posted by looter View Post
                                Is the early access version compatible with desktop game projects or is it mobile games only?
                                Hi looter,

                                Early Access includes complete and tested implementation for iOS & Android. Desktop version is still under development. Initial commit with desktop version will be available later this week (not production ready yet but good for testing). If you want to use this plugin in production, I'd recommend you to wait for final release. We are honest with our fans and customers. We know that developing process is too long but Realtime Database is not trivial thing and we don't want to release unstable software. Mobile version is production-ready so we decided to release it for people who needs it only for mobile. But desktop version needs a bit more tests and polishing. Thank you for your patience!
                                Realtime Database Firebase | Ultimate Mobile Kit Firebase | Extended Facebook | Universal Mobile Ads | Google Analytics

                                Comment

                                Working...
                                X