Android Features – Real-time Data Sync

Introduction

Certain use cases demand that Geo-fences, Beacons, and GEOLINE™, as well as the Actions and Conditions associated with them on the back-end, are synced to the mobile devices immediately. Bluedot Point SDK for Android can be optionally configured to receive push notifications to enable Real-time Data Sync. The present implementation supports integration through Google Firebase cloud messaging; future versions of the SDK will provide support for any other push infrastructures, giving you the flexibility to connect your existing push integrations. This documentation will guide you through the integration processes and steps to activate the Real-time Data Sync.

Integrate Firebase SDK into your project

To integrate Firebase, below are the prerequisites that must be met:

A device running Android 2.3 or higher and Google Play services 9.4.0 or later.

To add Firebase to your app, you will need to create a Firebase project and a Firebase configuration file. This can be achieved by following steps:

1. Create a new Firebase project in the Firebase console. If you have an existing Google project associated with your mobile app, you can import it by clicking Import Google Project. To create a new project click on Create New Project.

2. A new dialog will appear. Enter your project’s name and select your country/region and click Create Project.

3. You will be redirected to the project dashboard. Select Add Firebase to your Android app.

4. A new dialog will appear asking for a package name and an optional SHA-1hash of your debug signing certificate. The package name can be retrieved from either the AndroidManifest.xml or the build.gradle file. Select ADD APP to add your app to Firebase project.

To retrieve the SHA-1 hash from the KeyStore, open Terminal on Mac/Linux or Command Prompt on Windows, and paste the relevant line below. If the prompt asks for a password, enter default password android.

5. A google-services.json file will be downloaded and saved to your browser’s default download directory. In Android Studio switch to Project view and move the downloaded google-services.json file into the app folder. Once done, press CONTINUE.

// Method 2: Add this line in the class code to disable analytics collection
FirebaseAnalytics.getInstance(context).setAnalyticsCollectionEnabled(false);

Bluedot Push Interface

To enable Push notifications from our Bluedot app, we need to subscribe to the topic using our Bluedot’s application API key. This is achieved using the code below. It is recommended to add the line to the onBluedotPointServicesStartedSuccess() callback.

The next step is to provide the received push notification’s data object to Bluedot’s notifyPushUpdate method, to process the push and trigger rule set refresh. This method is to be placed inside the onMessageReceived callback of your service that extends FirebaseMessagingService, demonstrated below.

Disclaimer: Bluedot Point SDK will only utilize the data of push notifications sent containing a unique Bluedot identifier, and will ignore all other push notifications.

The last step is to provide the Firebase Server key of your project to the Bluedot Point Access dashboard. The Firebase server key can be retrieved by opening Project Settings from your Firebase dashboard and opening the Cloud Messaging tab. From there you can copy the Server key.

On your Bluedot Point Access dashboard, select App and Beacon Managment, and from the list of apps, select More Details for the app for which you want to enable push notifications. Paste the Firebase server key into the Firebase API Key field and Save it.