This is the final article in a three-part series on building a multi-user iOS game app. In part 2 of this series, we demonstrated the process of player registration, login, and storing in Backendless Database. Now, let’s take a look at counting the score for every player, creating a leaderboard, and how all of the game installations are notified when this information changes.
For this series, we are developing an iOS game called “TapMe”. As TapMe is a multiplayer game, it provides registration for the new users and login for the existing ones. In this article, we are going to demonstrate how to handle user registration and login, as well as how to store a player’s information in the database.
With the introduction of the real-time database, Backendless is a great platform for developing games, especially multi-user ones. In this series of posts, I will be showing to you how to build a game for iOS with Swift using Backendless. For a quick overview of the game in action, please watch the video below:
Backendless and Firebase, both being mobile BaaS platforms, are presenting different capabilities for mobile apps creation.
Here is a list of the Backendless features which either are not supported by Firebase or just exceed it in usability.
Backendless Pro (the standalone, self-hosted version of the product) can be installed on the developer’s computer, a private data center or a public cloud. No matter where it’s installed, the product has no functional limitations whatsoever
With Backendless you can fully customize permissions for users, and also configure permissions for custom user roles, which is not supported by Firebase
Backendless allows you to develop the server-side algorithms and business logic without actually writing any code using Codeless Programming
Firebase does not support native aggregate functions in database queries. With Backendless, you can calculate average, sum, min and max values for a collection of objects without retrieving objects from the server. It is also possible to find the object count for all the records in the database or a subset of records For example, the aggregate function sum allows you to calculate the mathematical sum for a set of objects. For instance, you can take the
Movie table from the presented database. Just run the following query to get the amount of
topBoxOffice of all movies:
GET https://api.backendless.com/<appid>/<REST API key>/data/Movie?props=Sum(totalBoxOffice)
The output is an object with the
Backendless also supports results grouping for a column. This column can either be found in the original or linked table. For example, the following query will display the sum of all the orders grouped by a country:
GET https://api.backendless.com/<app id>/<REST API key>/data/Orders?props=Sum(orderAmount)&groupBy=relatedCountry.countryName
The output for this request is a collection of objects, any of which contains the total amount of orders for a particular country:
You can also add a filter to the grouped objects using the
having condition. The following query will return only groups of countries with the total amount of orders
>10000 . The output for this request is a collection of objects, any of which contains the total amount of orders for a particular country:
GET https://api.backendless.com/<app id>/<REST API key>/data/Orders?props=Sum(orderAmount)&groupBy=relatedCountry.countryName&having=Sum(orderAmount)>10000
Since Firebase uses JSON document as a database, it becomes extremely difficult (or in many cases impossible) to create relations between objects. Backendless makes it convenient to manage the relations (create, modify, delete) both via Console and with the API. In Firebase, you need to duplicate the data for each element, which causes synchronization problems for the identical objects that have one-to-many relations.
It is worthwhile to point out the following:
Backendless allows you to import data from Parse. Importing data from external databases will become available soon as well