This website is no longer maintained. Please, visit documentation.indigitall.com to read our updated documentation.

Android SDK

advanced guide to configure the Android SDK

Index

1. Configurable properties

In this section you will find a series of more advanced functionalities that require a more complex development. We recommend that a developer be in charge of this configuration.

1.1. Activate geolocated notifications

The indigitall SDK can manage the user's location. This allows you to use the location filters on the send push campaign screen ( Campaigns> Push> New push campaign > Filters> Geographical filters)


Location path on console

Once we have enabled this functionality, the end user will have to give their consent to the location permission and enable the location services of their smartphone, so that the application can obtain the exact location of the user.

Add localization permissions by including this line in the AndroidManifest.xml file:


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


You can find the AndroidManifest.xml file in the following path:


Ruta al fichero AndroidManifest.xml

Options to keep in mind

There are two ways to manage location permissions:

  • Manual: It is the default option and the developer is in charge of managing the location permissions.
  • Automatic : It is the SDK that manages the location permissions.


Here we explain how to configure location permissions in automatic mode.


The AutoRequestPermissionLocation parameter must be added when the SDK is initialized. This is done using the following code excerpt:


//When you want to initialize indigitall
Configuration config = new Configuration
    .Builder("<YOUR-APP-KEY>", "<YOUR-SENDER-ID>")
    .setAutoRequestPermissionLocation(true)
    .build();
Indigitall.init(context, config);


In Android there is a class where the status of the permissions is received after the user has changed them through the configuration. The following piece of code should be added to capture the status of the permissions:


//In the class you use to receive the results of asking for the permissions
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    Indigitall.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
}

1.2. Set the default Activity

The Activity by default is the initial screen of your app that is launched when a user clicks on a notification that does not have a deeplink. It is also the point where you should initialize the SDK. It is set by the DefaultActivity parameter:


//When you want to start indigitall
Configuration config = new Configuration
    .Builder("<YOUR-APP-KEY>", "<YOUR-SENDER-ID>")
    .setDefaultActivity("YOUR_ACTIVITY")
    .build();
Indigitall.init(context, config);

1.3. Associate the device with a user

You can associate your own ID to each device. In this way it will be easier and more intuitive for you to work with our tool. For example:

  • If your users have been identified, you could use your user ID, or email, or any other data that you are used to working with.
  • If your users are anonymous because they have not logged into the app, you may have a Google Analytics or Commscore metric system. You could use the ID provided by these tools.


To make this association between your custom ID (externalId), and the identifier handled by indigitall (deviceId), you have to invoke the setExternalCode method:


//Remember to put your external code here
Indigitall.setExternalCode(this, "YOUR_EXTERNAL_ID", new DeviceCallback(context) {
    @Override
    public void onSuccess(Device device) {
        //DO SOMETHING
    }
    @Override
    public void onFail() {
        //LOG ERROR
    }
});


Do not worry about anything. Your IDs are irreversibly encrypted on the phone itself and sent securely to our servers. Not even the indigitall team can know this information.

1.4. WiFi filter

If it is required to collect the user's WiFi information, in addition to the configuration of the Indigitall panel, you must add in the manifest the permissions that are exposed below, the service corresponding to the filter and add the parameter wifiFilterEnabled when it is initialize the SDK:


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

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

  // ANDROID 12 WIFI
  <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

//WiFi service
<service
    android:name="com.indigitall.android.services.WifiStatusService"
    android:permission="android.permission.BIND_JOB_SERVICE" >
</service>

<receiver android:name="com.indigitall.android.receivers.WifiWakeLockReceiver">
    <intent-filter>
        <action android:name="AlarmReceiver.Action.NETWORK_ALARM" />
    </intent-filter>
</receiver>

//When you want to start indigitall
Configuration config = new Configuration
    .Builder("<YOUR-APP-KEY>", "<YOUR-SENDER-ID>")
    .wifiFilterEnabled(true)
    .build();
Indigitall.init(context, config);
  • From android 8.0 to obtain the WiFi data, which are added to the manifest the location permissions. More information here: Android Developers

  • Please note that the WiFi scan time when the app is in the background or closed may be inaccurate.

1.5. Layout custom

If for some reason you don't want to show the push as the native android sample, we leave this option to show the push with our custom layout . To do this add the following code in the configuration before calling init:



//When you want to start indigitall
Configuration config = new Configuration
    .Builder("<YOUR-APP-KEY>", "<YOUR-SENDER-ID>")
    .setLayoutBasic(LayoutBasic.custom)
    .build();
Indigitall.init(context, config);
  • Remember that as of android 10, the custom layout will cause problems in displaying images if the mobile has dark mode activated. If the custom layout is not indicated, it will be displayed in native mode


1.6. Custom domain

if you are ENTERPRISE CUSTOMER you have to add this parameter in the configuration so that the SDK points to the correct environment:


Configuration config = new Configuration
    .Builder("<YOUR-APP-KEY>", "<YOUR-SENDER-ID>")
    .setUrlDeviceApi(YOUR_DEVICE_API_DOMAIN)
    .setUrlInAppApi(YOUR_INAPP_API_DOMAIN)
    .setUrlInboxApi(YOUR_INBOX_API_DOMAIN)
    .build();
Indigitall.init(context, config);


2. Callbacks offered by the SDK

Our SDK offers various callbacks that help you have greater control of the execution flow and implement custom behaviors.


To subscribe to these callbacks you have to:

  • Instantiate the InitCallBack object and pass it as the third parameter of the init method.
  • Override the methods that the InitCallBack class implements.


Indigitall.init(context, config, new InitCallBack(context){
   @Override
    public void onIndigitallInitialized(Permission[] permissions, Device device) {}
    @Override
    public void onNewUserRegistered(Device device) {}
    @Override
    public void onErrorInitialized(String error) {}
});

 2.1. Initialized SDK

The method onIndigitallInitialized of the InitCallBack object will execute when the SDK finishes initializing and the device is ready to receive notifications from indigitall.


Receive as parameter:

  • An array of Permission objects. The first item is the status of the claims permission. The second item is the status of the locate permission.
  • A Device object with the information associated with the device.


Here is an example that prints logs about the status of permissions and device information.


Indigitall.init(context,config, new InitCallBack(context){
   @Override
    public void onIndigitallInitialized(Permission[] permissions, Device device) {
        super.onIndigitallInitialized(permissions, device);
        Log.d("Push Permission: ", permissions[0].toString());
        Log.d("Location Permission: ", permissions[1].toString());
        Log.d("Device: ", device.toString());
    }
});

 2.2. New registered device

The method onNewUserRegistered of the InitCallBack object will be executed when the device has been registered for the first time, that is, in the first execution of the app after being installed.


It receives as a parameter the Device object with the information associated with the device.


Indigitall.init(context, config, new InitCallBack(context){
    @Override
    public void onNewUserRegistered(Device device) {
        super.onNewUserRegistered(device);
        Log.d("Device: ", device.toString());
    }
});

 2.3. An error has occurred

The onErrorInitialized method of the InitCallBack object will be executed only if an error occurs during the initialization of the SDK.


It receives the description of the error as a parameter.


Indigitall.init(context, config, new InitCallBack(context) {
    @Override
    public void onErrorInitialized(String error) {
        super.onErrorInitialized(error);
        Log.d("Error on Indigitall.init: ", error);
    }
});

3. Manage device

3.1. Check device information and status

You can use the deviceGet method to get the information that the SDK has recorded regarding the device.


You must instantiate a DeviceCallback object and pass it as the second parameter of the deviceGet method. This callback will receive as a parameter the device object that contains all the information associated with the device.


Indigitall.deviceGet(context, new DeviceCallback() {
    @Override
    public void onSuccess(Device device) {
        Log.d("Device: ", device.toString());
    }
    @Override
    public void onFail() {}
});

3.2. Enable/disable device

You can choose to disable the device to block the receipt of notifications. It is a very useful method to:

  • Implement a preferences screen so that the user can enable / disable the receipt of notifications.
  • Avoid receiving notifications if the user has not logged in, or has not accepted the terms of use, etc.
  • Manage the Robinson List .


To do this, you have the deviceEnable and deviceDisable methods.


You must instantiate a _Device Callback object and pass it as the second parameter. This callback will receive as a parameter the device object that contains all the information associated with the device.


Indigitall.deviceEnable(context, new DeviceCallback(context) {
    @Override
    public void onSuccess(Device device) {
        Log.d("Device: ", device.toString());
    }
    @Override
    public void onFail() {}
});

Indigitall.deviceDisable(context, new DeviceCallback(context) {
    @Override
    public void onSuccess(Device device) {
        Log.d("Device: ", device.toString());
    }
    @Override
    public void onFail() {}
});

4. Interest groups

Our SDK allows you to classify users into different customizable groups. This is very useful for:

  • Implement a preferences screen so that the user can choose the topics for which they want to receive notifications.
  • Label according to the navigation or actions that the user performs.
  • Segment communications according to whether the user has identified or is anonymous.
  • Segment based on language, culture, customer category, or based on any other criteria you need.


Remember that you must first define the groups you want to work with in the indigitall console ( Tools> Interest groups </ a>). See our user manual for more info.

4.1. List groups

Use the topicsList method to get the list of groups that are configured in your indigitall project. The callback of this method receives as a parameter an array of Topics, which contains the information of all the available groups, as well as a flag that indicates whether the user is included in any of them.


Indigitall.topicsList(context, new TopicsCallback() {
    @Override
    public void onSuccess(Topic[] topics) {
        //DO SOMETHING
    }
    @Override
    public void onFail() {}
});

4.2. Manage subscription

To manage the device subscription to one or more groups, there are two methods: topicsSubscribe and topicsUnsubscribe .

Optionally, both receive a TopicsCallback object as the third parameter, which will return the list of all Topic in the project.


//topics is typeof Topic[] or typeof string[]
Indigitall.topicsSubscribe(context, topics, new TopicsCallback() {
    @Override
    public void onSuccess(Topic[] topics) {}
    @Override
    public void onFail() {}
});

//topics is typeof Topic[] or typeof string[]
Indigitall.topicsUnsubscribe(context, topics, new TopicsCallback() {
    @Override
    public void onSuccess(Topic[] topics) {}
    @Override
    public void onFail() {}
});

5. Send custom events

Your app can send information to indigitall's servers to identify the actions and events that happen in it. This allows you to automate retargeting actions.


To register these events you have to call the sendCustomEvent method, passing a descriptive ID as a parameter (you can invent the one you like best) and set data you need.


Indigitall.sendCustomEvent(context, "YOUR_EVENT_ID", JSONObject("YOUR_CUSTOM_DATA"),object: EventCallback(context){
    override fun onSuccess() {
        // Do something in success function
    }
    override fun onError(error: Error) {
        //SHOW ERROR
    }
});

6. In-App Messages

If you want to integrate the In-App messages in your application, you can do it with several complementary formats:

  • Banner. Static content that is always visible, but allows the user to continue using the application.
  • Popup. Full screen content that forces the user to click or discard the information.

6.1. Banner format

Below we tell you how to instantiate one or more In-App messages in banner format.

Remember that you should first have them defined in the indigitall console. See our user manual for more info.


Create a WebView view in your layouts. The size must match what you have defined in the indigitall console ( Tools> In-App / In-Web Schemas ). Remember to translate the units from PX to DP.


If it is configured in the console that the banner is hidden for X seconds, you have to add to the call the activity in which the inApp is located and add the callback didDismissed where it will indicate that the established time has elapsed, returning the web the inApp code so that you can, for example, hide it.

6.1.1. One single banner

You can follow the example below:


<WebView
    android:id="@+id/myBanner"
    android:layout_width="230dp"
    android:layout_height="33.33dp"
/>


Instantiate the In-App message using the showInApp method.


WebView view = findViewById(R.id.myBanner);

Indigitall.showInApp(getContext(), "myBanner_CODE", view, new ShowInAppCallback() {
    @Override
    public void onLoad(String inAppCode, WebView webView) {
        Log.d("In-App loaded: ", inAppCode);
    }
    @Override
    public void onSuccess(InApp inApp) {
        Log.d("In-App: ", inApp);
    }
    @Override
    public void onFail(String inAppCode, WebView webView, String message) {}
});

// If it is configured in the campaign so that the banner is hidden at X seconds:

Indigitall.showInApp(getContext(), "myBanner_CODE", view, new InAppCallback() {
    @Override
    public void onLoad(String inAppCode, WebView webView) {
        Log.d("InApp loaded: ", inAppCode);
    }
    @Override
        public void onSuccess(InApp inApp) {
            Log.d("In-App: ", inApp);
        }
    @Override
    public void onFail(String inAppCode, WebView webView, String error) {

    }

    @Override
    public void didDismissed(String inAppCode, WebView webView) {
        super.didDismissed(inAppCode, webView);        
    }
});

6.1.2. Multiple banner

You can follow the example below:


<WebView
    android:id="@+id/myBanner"
    android:layout_width="230dp"
    android:layout_height="33.33dp"
/>
<WebView
    android:id="@+id/otherBanner"
    android:layout_width="250dp"
    android:layout_height="36dp"
/>


Instantiate In-App messages using the showInApp method.


ArrayList<WebView> views = new ArrayList<>();
views.add(findViewById(R.id.myBanner));
views.add(findViewById(R.id.otherBanner));

ArrayList<String> codes = new ArrayList<>();
codes.add("myBanner_CODE");
codes.add("otherBanner_CODE");

Indigitall.showMultipleInApp(getContext(), codes, views, new ShowInAppCallback() {
    @Override
    public void onLoad(String inAppCode, WebView webView) {
        Log.d("In-App loaded: ", inAppCode);
    }
    @Override
    public void onSuccess(InApp inApp) {
        Log.d("In-App: ", inApp);
    }
    @Override
    public void onFail(String inAppCode, WebView webView, String message) {
         //show error if inApp is Expired, inApp was shown or clicked more than x times configured on indigitall console
    }
});

// If it is configured in the campaign so that the banner is hidden at X seconds:
Indigitall.showMultipleInApp(getContext(), inAppCodeList, webViewList, new InAppCallback() {
    @Override
    public void onLoad(String inAppCode, WebView webView) {
        Log.d("InApp loaded: ", inAppCode);
    }
    @Override
    public void onSuccess(InApp inApp) {
        Log.d("In-App: ", inApp);
    }

    @Override
    public void onFail(String inAppCode, WebView webView, String error) {
         //show error if inApp is Expired, inApp was shown or clicked more than x times configured on indigitall console
    }

    @Override
    public void didDismissed(String inAppCode, WebView webView) {
        super.didDismissed(inAppCode,webView);
        Log.d("InApp didDismissed " + inAppCode);
    }
});

6.2. Popup Format

Next we tell you how to instantiate an In-App message in popup format.

Remember that you should first have it defined in the indigitall console. See our user manual for more info.


Create a WebView view in your layouts. The size must match what you have defined in the indigitall console ( Tools> In-App / In-Web Schemas ). Remember to translate the units from PX to DP.


ConstraintLayout view = findViewById(R.id.myPopupParentLayout)

Indigitall.showPopUp(view, getContext(), "myPopup_CODE", new ShowInAppCallback() {
    @Override
    public void onLoad(String inAppCode, WebView webView) {
        Log.d("In-App loaded: ", inAppCode);
    }
    @Override
    public void onSuccess(InApp inApp) {
        Log.d("In-App: ", inApp);
    }
    @Override
    public void onFail(String inAppCode, WebView webView, String message) {}

    @Override
    public void didClicked() {
        Log.d("popUp","didClicked")
    }

    @Override
    public void  didClosed() {
        Log.d("popUp","didClosed")
    }
    @Override
    public void  didDismissed() {
        Log.d("popUp","didDismissed")
    }
    @Override
    public void onShowTimeFinished(
        String inAppCode,
        WebView webView,
        int showTime
    ) {
        Log.d("popUp", "onShowTimeFinished")
    }
    @Override
    public void didDismissForever(InApp inApp, Error error) {
        Log.d("Popup", "didDismissForever ")
    }
});


If you want to customize the icon to close the Popup, you can do it with the following method to which you can pass a custom ImageButton , if you wanted to use our icon, just pass a null. The closeIconDisabled parameter is in case you don't want to show any icon, setting it to true to hide it or false to show it.


ConstraintLayout view = findViewById(R.id.myPopupParentLayout)

ImageButton myImageButton = ImageButton(context);
.
.//set ImageButton params
.
boolean closeIconDisabled = false

Indigitall.showPopUp(view, getContext(), "myPopup_CODE", myImageButton, closeIcon, new ShowInAppCallback() {
    @Override
    public void onLoad(String inAppCode, WebView webView) {
        Log.d("In-App loaded: ", inAppCode);
    }
    @Override
    public void onSuccess(InApp inApp) {
        Log.d("In-App: ", inApp);
    }
    @Override
    public void onFail(String inAppCode, WebView webView, String message) {}

    @Override
    public void didClicked() {
        Log.d("popUp","didClicked")
    }

    @Override
    public void  didClosed() {
        Log.d("popUp","didClosed")
    }
    @Override
    public void  didDismissed() {
        Log.d("popUp","didDismissed")
    }
    @Override
    public void didDismissForever(InApp inApp, Error error) {
        Log.d("Popup", "didDismissForever ")
    }
});

6.3. InApp Utilities

In the event that you want to show the InApp scheme in a different way to how our SDK paints it, we put at your disposal some methods so that you can customize the "painting", without affecting the statistics or the InApp functionalities.

InApp object pickup


InAppIndigitall.inAppGet(context, inAppId, new InAppCallback(context){    
    @Override
    public void onFail(Error error) {
        super.onFail(error);
    }

    @Override
    public void onSuccess(InApp inApp) {
        //DO SOMETHING
    }
});

Check if the InApp should be displayed

Thanks to the InApp functionalities (from version 4.18.0 ), it is possible to indicate that the inApp is displayed or pressed a maximum number of times, or if in the case of the popUp, after performing an action , such as pressing the close button, is not shown again. To do this we could do the following within the inAppGet method that we have seen previously:


InAppIndigitall.inAppGet(context, inAppId, new InAppCallback(context){    
    @Override
    public void onFail(Error error) {
        super.onFail(error);
    }

    @Override
    public void onSuccess(InApp inApp) {
        if (inApp.getProperties().getDismissForever() &&
                PopUpUtils.INSTANCE.isInAppDismissForever(context, inApp)) {
            //InApp was dismissed forever
        } else {
            InAppUtils.INSTANCE.inAppWasShown(context, inApp, new InAppWasShownCallback() {
                @Override
                public void didExpired() {
                    //InApp  was expired
                }

                @Override
                public void didShowMoreThanOnce() {
                    //InApp  was shown more than" + inApp.getProperties().getNumberOfShows() +" times"
                }

                @Override
                public void didClickOut() {
                    //InApp  was clicked more than " + inApp.getProperties().getNumberOfClicks()+ " times"
                }

                @Override
                public void onSuccess() {
                    //SHOW INAPP OR DO SOMETHING
                }
            });
        }
    }
});

Actions to count clicks or to not show InApp anymore

For the case of what we call Dismiss Forever, once the action is performed, this method must be called:


PopUpUtils.INSTANCE.addNewInAppToDismissForever(context, inApp);

In the event that you want to show an inApp only if you make 'x' clicks or clicks on it, you must add the following:


Boolean result = InAppUtils.INSTANCE.inAppWasClicked(context, inApp, intent);
  • In this method the statistics of the click are sent, not just the click counter, so it returns a boolean just to confirm that everything has gone correctly.


7. Inbox

7.1. Inbox configuration

In this section you will find a series of more advanced functionalities that require a more complex development. We recommend that a developer be in charge of this configuration.

7.1.1. User identification

In order to get the notifications from Indigitall's Inbox, the user must identify himself. First you have to initialize the SDK of Indigitall so that it generates our identifier (deviceId) and be able to associate it with the custom ID that you associate to the device, similar to how is explained here .


To perform the registration tasks, these two methods are used:


//User ID
Indigitall.logIn(this, "YOUR_EXTERNAL_ID", new DeviceCallback(context) {
    @Override
    public void onSuccess(Device device) {
        //DO SOMETHING
    }
    @Override
    public void onFail() {
        //LOG ERROR
    }
});

//Disconnection
Indigitall.logOut(this, new DeviceCallback(context) {
    @Override
    public void onSuccess(Device device) {
        //DO SOMETHING
    }
    @Override
    public void onFail() {
        //LOG ERROR
    }
});

7.1.2. Generate authentication token

In this section you will see how to generate a validation token for an application that has configured authentication with webhook. To generate this token, you need to add the JSON with the configuration.


The token has a predetermined expiration date, once it has expired in our system, a listener event of type InboxAuthListener will be fired indicating said expiration and will have to return the configuration JSON. To collect the listener, you have to implement it in the corresponding class, and override the following method:



public class YOUR_CLASS implements InboxAuthListener{
.
.
.
@Override
public JSONObject getAuthConfig() {
    return MY_JSON;
}

7.2. Inbox main features

Once the device has been successfully registered, you can start making Inbox requests. The following characteristics of the Inbox must be taken into account, which are optionally configurable.

7.2.1. Inbox Properties

The notifications of the Inbox will have the following states of the class InboxStatus:


  • Sent : The notification has been sent to the client, whether or not they could read it.
  • Click: have clicked on the notification displayed in the Inbox.
  • Delete : The Inbox notification has been deleted by the customer.


The notifications will also come with a 'read' status, to help differentiate those status.


Each notification will be assigned with an integer and unique sendingId, to be able to differentiate them and use them for some of the functionalities.


In the particular case of Android, when a new push from Indigitall arrives at the client device, an action defined in an intent is generated, which can be used to notify the user that they have a new message in the Inbox. To collect it, it must be implemented in the following way:


@Override
protected void onResume() {
    super.onResume();
    if (getIntent() != null && getIntent().getExtras() != null){
        Bundle extras = getIntent().getExtras();
        if( extras != null && extras.containsKey(Push.EXTRA_PUSH)) {
            //DO SOMETHING
        }
    }
}

7.2.2. Obtain notifications

As explained above, to obtain the notifications the following method is used:


 Inbox.Companion.getInbox(context, new InboxCallback(context) {
    @Override
    public void onSuccess(Inbox inbox) {
        //DO SOMETHING
    }

    @Override
    public void onError(Error error) {
        //LOG ERROR
    }
});
7.2.2.1 Next page

Once the Inbox instance is obtained, we will use it to request the next page, which is made with the following method, in the event that there are no more pages it will indicate it in the error with the code 410:


inbox.getNextPage(context,new InboxCallback() {
    @Override
    public void onSuccess(Inbox inbox, newNotifications: ArrayList<InboxNotification>?) {
        //DO SOMETHING
    }

    @Override
    public void onError(Error error) {
        if (error.code == 410){
            //LOG NO HAY MÁS PÁGINAS
        }else{
            //LOG ERROR
        }
    }
});


Take into account that the Inbox callback, apart from returning the updated Inbox, returns an array called newNotifications , in which the new notifications to be added to the Inbox will be displayed, so that, if necessary, be able to use said array to move between the pages without depending on the Inbox calls.

7.2.3. Get the information from a notification

To get the information of a particular notification, you have to make the following call with the sendingId of each notification:


inbox.getInfoFromNotification(context, SENDING_ID , new InboxNotificationsCallback(context) {
    @Override
    public void onSuccess(InboxNotification inboxNotification) {
        //DO SOMETHING
    }

    @Override
    public void onError(Error error) {
        //LOG ERROR
    }
});

7.2.4. Edit the status of one or more notifications

To edit the status of one or more notifications at the same time, it is done with the following method in which you must indicate the sendingIds of the notifications to edit and the status to which you want to change:

//Modify a notification
inbox.modifyStatusFromNotification(context,SENDING_ID,STATUS,new InboxNotificationsCallback(context) {
    @Override
    public void onSuccess(InboxNotification inboxNotification) {
        //DO SOMETHING
    }

    @Override
    public void onError(Error error) {
        //LOG ERROR
    }
});

//Massively modify
inbox.massiveEditNotifications(context,[SENDING_IDS],STATUS,new BaseCallback() {
    @Override
    public void onSuccess(JSONObject json) {
        //DO SOMETHING
    }

    @Override
    public void onError(Error error) {
        //LOG ERROR
    }
});

7.2.5. Notifications status counters

To find out the number of notifications in the Inbox according to their status, this method is performed:

Inbox.Companion.getMessagesCount(context, new InboxCountersCallback(context) {
        @Override
        public void onSuccess(InboxCounters inboxCounters) {
            //DO SOMETHING
        }
    });

8. Firebase Utils

If you have custom Firebase classes, you may need to disable the following SDK services, defined in the manifest.xml.


<!-- <service
    android:name="com.indigitall.android.services.FirebaseMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>
    <service
    android:name="com.indigitall.android.services.FirebaseInstanceIdService">
    <intent-filter>
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
    </intent-filter>
</service> -->


If this is your case, you must add this code to ensure that notifications sent from indigitall are received and displayed.


In the service associated with the action _com.google.firebase.INSTANCE_IDEVENT add this line to register the push token.


@Override
public void onTokenRefresh() {
    FirebaseUtils.setPushToken(context);
}


In the service associated with the _com.google.firebase.MESSAGINGEVENT action, if the notification comes from indigitall , the following lines of code will cause it to be painted.



//Google
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    if(remoteMessage.getData() != null && !FirebaseUtils.pushNotificationIndigitall(remoteMessage, context)){
        //Your Code
    }
}

//Huawei
 override fun onMessageReceived(newRemoteMessage: RemoteMessage?) {
        if(remoteMessage.getData() != null && !HMSUtils.pushNotificationIndigitall(remoteMessage, context)){
        //Your Code
    }
 }    

9. Collection of push data

In the event that you would like to obtain the push object of type json to carry out checks or actions that your application requires, we leave you this code that will help to obtain it:


@Override
protected void onResume() {
    super.onResume();
    if (getIntent() != null && getIntent().getExtras() != null){
        Bundle extras = getIntent().getExtras();
        if( extras != null && extras.containsKey(Push.EXTRA_PUSH)) {
            Push push = new Push(extras.getString(Push.EXTRA_PUSH));
        }
    }
}

In the case of encrypted push, the Push object must be passed the context as an additional parameter:

@Override
protected void onResume() {
    super.onResume();
    if (getIntent() != null && getIntent().getExtras() != null){
        Bundle extras = getIntent().getExtras();
        if( extras != null && extras.containsKey(Push.EXTRA_PUSH)) {
            Push push = new Push(context,extras.getString(Push.EXTRA_PUSH));
        }
    }
}

9.1. Register statistics if the Push action is involved.


If you decide to treat the Push action independently without going through our SDK, the intent of the action is collected in your activity where the ServiceUtils.RegisterStatistics method should be called. For this case, you can, for example, create a class that extends from our PushNotification to generate the intent with the following extras:


public class MyPushNotification extends PushNotification {
    Push push;
    Context context;

    public MyPushNotification(Push push) {
        super(push);
        this.push = push;
    }

    @Override
    public void showNotification(Context context) {
        this.context = context;
        super.showNotification(context);
    }

    protected PendingIntent getIntent(PushAction action, int clickedButton) {      
        Intent intent = action.getIntent(context);
        Intent indigitallIntent = new Intent(context, YOUR_ACTIVITY.class);
        indigitallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        indigitallIntent.putExtra(StatisticService.EXTRA_APP_KEY, PreferenceUtils.getAppKey(context));
        indigitallIntent.putExtra(StatisticService.EXTRA_PUSH_ID, push.getId());
        indigitallIntent.putExtra(StatisticService.EXTRA_CLICKED_BUTTON, clickedButton);
        indigitallIntent.putExtra(StatisticService.EXTRA_INTENT_ACTION, intent);
        indigitallIntent.putExtra(Push.EXTRA_PUSH, push.toString());
        if (action.getTopics() != null && action.getTopics().length>0){
            indigitallIntent.putExtra(StatisticService.EXTRA_ACTION_TOPICS, action.topicsToString());
        }
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
        stackBuilder.addNextIntentWithParentStack(indigitallIntent);

        return stackBuilder.getPendingIntent((push.getId()*10) + clickedButton, PendingIntent.FLAG_UPDATE_CURRENT);
    }
}


Once the push has been collected as explained in the previous section, the following method must be called to register statistics:

ServiceUtils.registerStatistics(context,indigitallIntent);


10. Reference documentation

SDK 4.8 Javadoc for Android


11. Changelog

[4.19.1] - 03/2022

Fixes

  • Improve the performance of API calls

[4.19.0] - 03/2022

Added

  • Delete the HMS libraries to avoid publication problems in the Play Store

[4.18.5] - 02/2022

Added

  • Update huawei push lib to compatibility android 31

[4.18.4] - 02/2022

Fixes

  • Fix posible error on device external app null

[4.18.3] - 02/2022

Fixes

  • Save device status in SharedPreferences

[4.18.2] - 01/2022

Fixes

  • Change conditionals with preference to avoid use HMS libraries in android ssoo

[4.18.1] - 01/2022

Fixes

  • Delete huawei Base library

[4.18.0] - 01/2022

Added

  • InApp Dismiss Forever
  • InApp utilities (numberOfClicks, numberOfShows)
  • Event custom para iurny

[4.17.5] - 12/2021

Fixes

  • Add field to PUT request when push secure is active

[4.17.4] - 12/2021

Fixes

  • Open URL action if android OS is 11 or higher

[4.17.3] - 11/2021

Fixes

  • Add campaignId on push click

[4.17.2] - 11/2021

Fixes

  • Handle error in case google-service.json is wrong set

[4.17.1] - 11/2021

Fixes

  • Reguster device

[4.17.0] - 10/2021

Added

  • Category field in Inbox notifications

[4.16.2] - 10/2021

Fixes

  • Xamarin library compatibility

[4.16.1] - 10/2021

Fixes

  • CustomerField model

[4.16.0] - 10/2021

Added

  • Compatibility with Android 12

[4.15.0] - 09/2021

Added

  • Customer Service

[4.14.0] - 09/2021

Added

  • InApp click control

[4.13.2] - 08/2021

Fixes

  • Add callback inApp with object InApp.

[4.13.1] - 07/2021

Fixes

  • Update HMS libs

[4.13.0] - 07/2021

Added

  • Updated sdk target version to 30
  • Update FirebaseMesssaging lib to 22.0.0

[4.12.4] - 07/2021

Fixes

  • Fix scale popup by terminal density

[4.12.3] - 06/2021

Fixes

  • Update HMS Core libs

[4.12.2] - 06/2021

Fixes

  • Update HMS libs

[4.12.1] - 06/2021

Added

  • New class HMSUtils to handle push

[4.12.0] - 05/2021

Added

  • New method to send custom event with data

    Fixes

  • Get Info from devices

[4.11.0] - 05/2021

Added

  • Hide the inApp after a time configured in the console

[4.10.2] - 04/2021

Fixes

  • PopUp show a number of times defined in the console

[4.10.1] - 04/2021

Fixes

  • Improve inApp model
  • Hide Close icon popUp

[4.10.0] - 04/2021

Added

  • InApp action open app
  • InApp show a number of times defined in the console
  • PopUp rounded edges

[4.9.9] - 03/2021

Fixes

  • Set correctly default activity

[4.9.8] - 02/2021

Fixes

  • Improve handling of button actions

[4.9.7] - 02/2021

Fixes

  • Improve control in case deviceId has not been generated
  • Fix PushNotification class extension in Harmony

[4.9.6] - 02/2021

Fixes

  • Improve performance in silent pushes

[4.9.5] - 02/2021

Fixes

  • Improve asynchronous call model

[4.9.4] - 02/2021

Fixes

  • Access to the HMSMessagingService Service

[4.9.3] - 01/2021

Fixes

  • Force token update due to expiration if not stored in the first instance

[4.9.2] - 01/2021

Fixes

  • Correctly display the body in android 6.0 and lower

[4.9.1] - 12/2020

Fixes

  • Stability in requests

[4.9.0] - 11/2020

Added

  • Persistent push

[4.8.6] - 10/2020

Fixes

  • Scale popUp and add callbacks
  • Sending statistics

[4.8.5] - 10/2020

Fixes

  • Add custom layout
  • Access to showNotification method

[4.8.4] - 10/2020

Fixes

  • Platform data

[4.8.3] - 09/2020

Fixes

  • Image in pushes in devices in huawei

[4.8.2] - 09/2020

Fixes

  • Fit popup to device size
  • Callback onErrorInitialized on domain error

[4.8.1] - 08/2020

Fixes

  • Control of errors in obtaining push in old huawei devices.

[4.8.0] - 08/2020

Added

  • Push with encrypted data

[4.7.0] - 07/2020

Added

  • Location service with HMS

[4.6.0] - 06/2020

Added

  • HMS - Huawei Mobile Services

[4.5.1] - 06/2020

Fixes

  • Icon in pushes with native layout

[4.5.0] - 06/2020

Added

  • Inbox

[4.4.0] - 06/2020

Added

  • Open * .pkpass files

[4.3.0] - 05/2020

Added

  • Native default layout

Fixes

  • Dark mode

[4.2.0] - 04/2020

Added

  • WiFi filter

[4.1.1] - 03/2020

Fixes

  • Collecting exceptions in PopUp type inApp

[4.1.0] - 03/2020

Added

  • No Action' function in inApp

[4.0.2] - 03/2020

Fixes

  • First location request

[4.0.1] - 01/2020

Fixes

  • Button action without subscription to topics

[4.0.0] - 03/2020

Added

  • Added subscribe topics with buttons
  • AndroidX Library

[3.1.0] - 08/2019

Added

  • Added sendCustomEvent method to send custom events