Setting Up and Getting Firebase Credentials

In order to use the CloudPersistence methods in dedicated applications, it is required to create and set up a database in firebase. In case this configuration is not completed, the application will not be able to use any CloudPersistence methods and an exception will be thrown when executing them.

 

When the configuration entered in mat|r is not valid, it results in the application access failure with an exception and this will not be executed.

 

Firebase configuration steps:

 

  1.       Creating a Google account

First, create an account in Google by accessing https://accounts.google.com/SignUp. In case of having one already and it is available for firebase, proceed with the next step.

 

  1.    Logging in on Firebase

Log in on https://firebase.google.com/?hl=es. Just click on ‘SIGN IN’ and, then, fill in with the Google username and password.

 

  1.    Creating the project

Once logged in, enter the list of projects by clicking on ‘GO TO CONSOLE’ which is on the top right-hand side of the page. This tab will head you to https://console.firebase.google.com/. There, create a project for the application. Notice that there are no projects yet; so click on ‘ADD PROJECT’. In case you already have a project and wish to use it, head to step 4.

 

There will appear a window where the app information must be entered: database name, selecting the corresponding country or region and, finally, checking on the firebase use conditions box. After this, click on ‘CREATE PROJECT’.

 

Next, click on ‘CONTINUE’ and you will be taken to the project ‘overview’.

 

  1.    Adding applications to the project

The application for Android and iOS must be added in order to get the credentials for the dedicated application.

 

4.1.  Android:

Access Android by clicking on ‘Add Firebase to you Android application’. In the next window, enter the ‘Android package name’ which must be the same as the one entered in the field ‘Package Name’ in the platform. After this, click on ‘REGISTER THE APPLICATION’.

 

Download the ‘google-services.json’ file which provides Firebase when clicking on ‘Download google-services.json’. This file contains all the information needed for the configuration: ‘firebase_url’, ‘api_key’ and ‘mobilesdk_app_id’.

 

google-service.json example

 

Next, go back to firebase and close the creating window for Android by clicking on the cross button on the left side of the title.

 

4.2.  iOS

Head to iOS application creation by clicking on ‘ADD ANOTHER APPLICATION’. Next, click on ‘Add Firebase to you iOS app’. When prompted, fill in the field ‘iOS bundle ID’ with the same name as the one entered in the field ‘Android package name’ in the Android configuration.

 

Click on ‘REGISTER THE APPLICATION’ and download the ‘GoogleService-info.plist’ file, which contains: ‘API_KEY’, ‘GCM_SENDER_ID’, ‘DATABASE_URL’ and ‘GOOGLE_APP_ID’.

 

GoogleService-info.plist example

 

Close the configuration window by clicking on the cross button on the left side of the title.

 

  1.    Initiating the database

Finally, head to the database to initiate it and change the security rules, which are necessary to determine who has read and write access to your database.

 

To do so, access ‘Database’ which is located on the left side panel. ‘Realtime Database’ is the database to use. Once there, click ‘START’ and the security rules configuration window will be opened. Next, click on ‘demo mode’ and, then, click on ‘ENABLE’ in order to allow the use of the database with the application.

 

Note: in case this step is not performed, the application’s initial load will not succeed due to the lack of access permission.

 

  1.    Mat|r configuration

Once you have gotten the credentials, head to configure the dedicated application in the mat|r platform. There, access the application, head to the ‘Build App’ tab and enter the credentials as shown below:

 

Note: the values ‘firebase_url’ and ‘DATABASE_URL’ are the same.

 

After entering the credentials, the dedicated application can be downloaded. This will be connected to the firebase database configured as shown below.

 

Valid configuration example in relation to the one gotten in firebase.