If you've completed the steps described in the Setup guides, you are now ready to implement our Android library in your app. Our library supports Android version 4.0 and up, but is only fully functional from version 4.1 (JellyBean) up to Android 8.0 (Oreo).

If you are upgrading from an older version of our library, it's always a good idea to read our Upgrade file.

Add Dependencies

For your convenience we've created a Maven repository that simplifies how you include our library in your app. Open the /app/build.gradle file in your project and add the following entries:

repositories {
    maven {
        url ""
dependencies {
    compile 're.notifica:notificare-push-lib-android:1.15.0'
    //compile 'org.altbeacon:android-beacon-library:2.15.1'

This will make sure you have the latest Notificare, Google Play and Support libraries. Additionally if you want to use implement beacons, you can add the Altbeacon library.

Add a Notificare Configuration file

In order to connect your app to Notificare, you must create a file /app/assets/ with the following contents:

developmentApplicationKey = xxx
developmentApplicationSecret = xxx
productionApplicationKey = xxx
productionApplicationSecret = xxx
production = false

It is recommended that you create at least two different apps in Notificare using separated environments for development and production. For each app you will have a different set of keys, these keys should be copied and pasted in the file shown above. The production property should be changed according to the environment you are building for. You can find your app keys by expanding your app's Settings menu item and clicking in App Keys as shown below:


Copy both the Application Key and Application Secret:


Add Firebase Cloud Messaging

Android Studio makes it easy to quickly import the FCM project you've created previously in your app. Simply expand in Tools menu and click in Firebase:

android studio tools firebase

This will open an Assistant window like the one below:

android studio firebase assistant

Simply click in the Set up Firebase Cloud Messaging and follow the guides in the following screen:

android studio firebase setup

Completing point 1 and 2 will prepare your app with everything needed to use the FCM project you've previously created. You can confirm if everything is created correctly by checking if a new entry under the dependencies, in your /app/build.gradle, was created as follows:

dependencies {
    compile 're.notifica:notificare-push-lib-android:1.15.0'
    compile ''
    //compile 'org.altbeacon:android-beacon-library:2.15.1'

And if a file /app/google-services.json was created. This file will have the information about the Sender ID of your FCM project.

Create an Intent Receiver

By default you could simply use the *re.notifica.push.gcm.DefaultIntentReceiver class as your Intent Receiver class, but in order to gain more control over Notificare, you will want to create your own Intent Receiver. This will make sure you can control device registration, notifications received, actions, etc. Go ahead and create a class like the one below:

public class MyIntentReceiver extends DefaultIntentReceiver {
    public void onReady() {
        // Enable this device for push notifications
        if (Notificare.shared().isLocationUpdatesEnabled()) {
            // Enable location updates. These updates will only be registered after the device is registered to Notificare, so this call could also go into the onRegistrationFinished below
            //To enable beacons please call the following method
        //To enable in-app billing please invoke the following method
    public void onRegistrationFinished(String deviceId) {
        // Typically, you want to override this method
        // The default behaviour is to register device with the registration Id assigned by GCM and no userId
        // You could, for example, register as the logged in user and set a device tag after registration
        String currentUserId = ...
        Notificare.shared().registerDevice(deviceId, currentUserId, new NotificareCallback<String>() {
            public void onSuccess(String result) {
                // We could also enable location updates here
                if (Notificare.shared().isLocationUpdatesEnabled()) {
                // After successful registration it is safe to set tags for this device
                ArrayList<String> tags = new ArrayList<String>();
                Notificare.shared().addDeviceTags(tags, new NotificareCallback<Boolean>() {
                    public void onError(NotificareError error) {
                        // Got error
                    public void onSuccess(Boolean success) {
                        // Tags set successfully
            public void onError(NotificareError error) {
                // Got error on device registration

Extend Base Application

For exactly the same reasons as you extend the Intent Receiver, you will also want to create your own Application class where you'll be launching Notificare's library, instead of using the re.notifica.push.gcm.BaseApplication. This will make sure you can customize the launching options as you see fit for your application. Go ahead and create a class like the one below:

public class MyBaseApplication extends Application {
    public void onCreate() {

        //Set debug logging
        //If you are using legacy GCM project uncomment the following line
        //Launch Notificare system

        //Crash logs are enabled by default, set it to false to disable them
        //Create and set default channel

        //Point to your own Intent Receiver

        //Uncomment this to keep the notification in the drawer after opening
        //Allow or disallow JS in notifications of type HTML or Webpage

        //Allow or disallow orientation changes

        // Uncomment to use a different icon for notifications
        // Uncomment to use a different accent color for notifications
        //Notificare.shared().setNotificationAccentColor(ContextCompat.getColor(this, R.color.notification_accent_color));
        // Uncommment this to show a notification light by default, even if it isn't sent with the incoming notification
        //Passbook related configuration
        //The SDK supports a single optional placeholder, %s.
        //If the placeholder is provided, it will be replaced by the pass description, if any.
        //Notificare.shared().setRelevanceText("Notificare demo: %s");

Android Manifest

Finally you will be adding permissions, configure the application and default activities in your Android Manifest file.

Locate your AndroidManifest.xml and add the following permissions:

<!-- REQUIRED for connecting to Notificare -->
<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<!-- REQUIRED to receive message -->
<uses-permission android:name="" />

<!-- Optional, add this permission if you are going to need in-app billing features  -->
<uses-permission android:name="" />

Finally make sure your application is declared as follows in your AndroidManifest.xml:

    android:theme="@style/AppTheme" >

    <!-- This will be the notification UI activity -->

    <!-- If you are using the loyalty add-on -->
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
                android:scheme="https" />

    <!-- FCM Manifest Entries -->
    <service android:name="re.notifica.push.fcm.PushService"
        android:label="Notificare Push Service">
            <action android:name="" />

    <service android:name="re.notifica.push.fcm.InstanceIDService"
            <action android:name="" />

    <!-- Point to your own Intent Receiver -->
    <receiver android:name=".MyIntentReceiver" />

    <!-- API key for Maps. It is needed when you want to push a map notification type. Get your Maps API Key from your Google API Console -->
        android:value="GOOGLE_MAP_KEY_HERE" />

    <!-- If you use custom URL Schemes in HTML and Website push notifications, you will want to provide them in this manifest. You will also want to create a resource file with an array of URL Schemes that can be handled in notifications. Any click or events that invoke these URL Schemes will then trigger a method in your custom Intent Receiver -->
        android:resource="@array/url_schemes" />


At this point, you have completed the basic setup of our library. Keep reading our implementation guides to dive deeper into each features available in our SDK.