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

Cordova SDK

advanced guide to configuring the Cordova 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.


Include the requestLocation parameter to your initialization.


...

window.plugins.indigitall.init({ appKey: "<YOUR_APP_KEY>", senderId: "<YOUR_SENDER_ID>", requestLocation: true });

...

1.2. 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:


window.plugins.indigitall.setExternalCode({externalCode: "YOUR_EXTERNAL_ID"}, (device) => {
            //DO SOMETHING
        },(error) => {
            //LOG ERROR
        });


Do not you 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.3. WiFi filter

If it is required to collect the user's WiFi information, in addition to the Indigitall panel configuration, you must add the parameter wifiFilterEnabled when the SDK is initialized:


window.plugins.indigitall.init({
  appKey: "<YOUR_APP_KEY>",
  senderId: "<YOUR_SENDER_ID>",
  wifiFilterEnabled: true
});


  • The location permission must be accepted by the user

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

1.3.1 Android permissions

In order to obtain the Wi-Fi information in android, the following permissions and services declared in the manifest are needed:


  <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>

1.3.2 iOS permissions

Likewise, you must add in the project options in Xcode, in Signing & Capabilities the option Access WiFi Information :


Access WiFi Information


1.4. 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:


window.plugins.indigitall.init({ 
    appKey: "YOUR_APPKEY", 
    ...
    urlDeviceApi: "YOUR_DEVICE_API_DOMAIN",
    urlInappApi: "YOUR_INAPP_API_DOMAIN",
    urlInboxApi: "YOUR_INBOX_API_DOMAIN",}


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.


window.plugins.indigitall.init({ appKey: "YOUR_APPKEY", senderId: "YOUR_SENDER_ID", requestLocation: true }, (device)=> {
            //LOG device
        }, (errorMessage)=>{
            //LOG ERROR
        });


 2.1. Initialized SDK


The device object that returns the callback 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. and when the SDK finishes initializing and the device is ready to receive notifications from indigitall.


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


window.plugins.indigitall.init({ appKey: "YOUR_APPKEY", senderId: "YOUR_SENDER_ID", requestLocation: true }, (device)=> {
            console.log("Device: ", Object.values(device));
        });

 2.2. An error has occurred

The error method will run only if an error occurs during the initialization of the SDK.


It receives the description of the error as a parameter.


window.plugins.indigitall.init({ appKey: "YOUR_APPKEY", senderId: "YOUR_SENDER_ID", requestLocation: true }, (device)=> {
            //LOG device
        }, (errorMessage)=>{
            console.log("Error: ", errorMessage;
        });

3. Manage device

This section describes the different actions that could be performed on an indigitall device. The device model would have this structure:


device = {
  deviceId: "string",
  pushToken: "string",
  browserPublicKey: "string",
  browserPrivateKey: "string",
  platform: "string",
  version: "string",
  productName: "string",
  productVersion: "string",
  browserName: "string",
  browserVersion: "string",
  osName: "string",
  osVersion: "string",
  deviceType: "string",
  enabled: "boolean",
  externalCode: "string"
};

3.1. Check device information and status

It returns a DeviceCallback if the operation is successful it returns a Device object.


window.plugins.indigitall.deviceGet((device) => {
  // Do something with device in success function
}, (error) => {
  // Do something in error function
});

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.


window.plugin.indigitall.deviceEnable((device) => {
  // Do something with device in success function
}, (error) => {
  // Do something in error function
});

window.plugin.indigitall.deviceDisable((device) => {
  // Do something with device in success function
}, (error) => {
  // Do something in error function
});

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 ). 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.


window.plugin.indigitall.topicsList((topics) => {
  // Do something with topics in success function
}, (error) => {
  // Do something in error function
});

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 String[]
window.plugin.indigitall.topicsSubscribe(topics, (topics) => {
  // Do something with topics in success function
}, (error) => {
  // Do something in error function
});

// topics is typeof String[]
window.plugin.indigitall.topicsUnsubscribe(topics, (topics) => {
  // Do something with topics in success function
}, (error) => {
  // Do something in error function
});

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 on JSON object.


window.plugins.indigitall.sendCustomEvent({event: "YOUR_CUSTOM_EVENT", customData:{}, () => {
    // Do something in success function
},(error) => {
    // Do something in error function
});

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.

6.1.1. One single banner

Create a div on your page. The size must match what you have defined in the indigitall console ( Tools> In-App / In-Web Schemas ).


<div id="divView" style="width:1250px; height:285px;"></div>


  • if a width and a height size different from the one we have defined in the console is assigned, it is likely that the InApp will not display correctly.


Once the code to show the InApp has been created, it must be instantiated and called in the showInApp method that we can see below. The code of the InApp, the id of the previous div, the appKey of the application and deviceId of the device and the appropriate callback must be passed as parameters to obtain the view and the code. This callback will tell us if it has been loaded correctly or not and in relation to this result we will do one action or another.

  • For ENTERPRISE clients you have to add the url for the inAppApi as a parameter:


A code example is here

window.plugins.indigitall.showInApp({
        divId: "divView_code",
        schemeId: "divView",
        appKey: appKey,
        deviceID: deviceId,
         urlInAppApi: "YOUR_INAPP_API_URL" //Enterprise Client
    }, (inAppCode, webView) => {
        // DO SOMETHING
    }, (inAppCode, webView, message) => {
        // Log error message
    }, (inApp, webView)=>{
        //showOntimeFinished
    });

6.1.2. Multiple banners

If we want to have several InApp to be shown in the flow of users, we must follow the following steps.


To do this, you must first create each div view on your page. Each of them must be assigned the same size that was created in InApp / inWeb Schemes of our indigitall console.


Such that:


  <div id="divView" style="width:1250px; height:285px;"></div>
  <div id="divViewTwo" style="width:980px; height:150px;" ></div>
  <div id="divViewThree" style="width:150px; height:950px;"></div>
...


Once all the views have been created, they must be instantiated using the showMultipleInApp method. Before reaching this call, a pair of arrays must be created. The first one is the list of the InApp codes while the second will contain the identifiers of the div where the InApp will appear. When the showMultipleInApp method is called, you have to pass it the list with the identifiers, the list with the div and also a callback that will be in charge of telling us if the operation has been successful or, on the contrary, an error has occurred.


let inAppCodeList = [];
inAppCodeList.push("divView_code");
inAppCodeList.push("divView_code_two");
inAppCodeList.push("divView_code_three");
...

let divList = [];
divList.push("divView");
divList.push("divViewTwo");
divList.push("divViewThree");
...

window.plugins.indigitall.showMultipleInApp({
      divId: divList,
      schemeId: inAppCodeList,
      appKey: appKey,
      deviceID: deviceId
  }, (inApp, webView) => {
      //DO SOMETHING
  }, (inAppCode, webView, message) => {
      // Log error message
  }, (inApp, webView, showTime)=>{
        //onShowTimeFinished
  });

6.2. PopUp format

It could be the case that you want to show an InApp with a PopUp.


Fortunately, in Javascript, to create an InApp as a PopUp you don't need a new procedure to create it. You can follow the same action as to show a single InApp.

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


window.plugins.indigitall.getInApp(inAppId, (inApp) => {
  //Do something
});

Check if the InApp should be displayed

Thanks to the InApp functionalities, 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:

window.plugins.indigitall.getInApp(inAppId, (inApp) => {
    window.plugins.indigitall.inAppWasShown(inApp,(inApp, divId, error) => {
      //didExpired
    }, (inApp, divId, error) => {
      //didShowMore
    }, (inApp, divId, error) => {
      //didClickOut
    }, (inApp, divId, error) => {
      //dismissForever
    }, (inApp, divId) => {
      //Show InApp
    }, (inApp, divId, error) => {
      //log error
    });
});

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:


window.plugins.indigitall.addNewInAppToDismissForever(inApp, () => {
  //success
}, (errorMessage) => {
  //error
});

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:

window.plugins.indigitall.addNewInAppClick({inApp:inApp, deviceId: deviceID, appKey: appKey}), () => {
  //success
}, (errorMessage) => {
  //error
});


7. Collection of push data

In the event that a silent keystroke is sent, or you want to collect the data of the keystroke before it is pressed, you must add the following method, which will return a remoteMessage in json format.

  window.plugins.indigitall.onMessageReceived(data => {
      //do something
  },(error)=>{
    // registration error
  });

To differentiate if the push is from indigitall or not, you can use this method, passing data obtained in the previous method:


  window.plugins.indigitall.isIndigitallPushNotification(data,()=>{
     //do something
  }, (error)=>{
      // registration error
  });

If you want to collect the token, add the following method:

    window.plugins.indigitall.getToken(token => {
        //do something
    },(error)=>{
      // registration error
    });

In the event that you want to obtain the push object of type json to perform checks and / or when the user clicks on the notification and is with the action of open app. The device model would have this structure:


push = {
  id: "int", 
    appKey: "string",
    title: "string",
    body: "string",
    icon: "string",
    image: "string",
    gif: "string",
    video: "string",
    action: {
          topics: ["string"],
          destroy: "boolean",
          type: "app | url | call | market | share",
          app: "string",
          url: "string",
          call: "string",
          market: "string",
          share: "string"
            }
    buttons: [{
          label:"string",
          action: {
                topics: ["string"],
                destroy: "boolean",
                type: "app | url | call | market | share",
                app: "string",
                url: "string",
                call: "string",
                market: "string",
                share: "string"
                  }
              }]
    data: "string",
    layout: "Layout",
    securedData: "string"
};


We leave you this code that will help to obtain it:


window.plugins.indigitall.getPush(push => {
    //DO SOMETHING
    },(error)=>{
      // Do something in error function
    });

8. Inbox

8.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.


Below we indicate the models of the objects that are used:



Inbox = {
    lastAccess: "string",
    count: "int",
    pageSize: "int",
    numPage: "int",
    notifications: [InboxNotifications],
    newNotifications: [InboxNotifications]
}

InboxNotifications = {
    id: "string",
    sentAt: "string",
    status: "String",
    sendingId: "int",
    campaignId: "string",
    message: Push
}

InboxCounter = {
    click: "int",
    sent: "int",
    deleted: "int",
    unread:{
        lastAccess: "string",
        count: "int"
    }

}
  • the Push object is indicated in section [7. Collection of the push data] (# 7-collection-of-the-data-of-the-push).

8.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 to the custom ID that you associate to the device, similar to how here .


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


//User ID
window.plugins.indigitall.logIn("YOUR_ID",(device)=>{
                //DO SOMETHING  
            }, (error)=>{
                //LOG ERROR 
            });

window.plugins.indigitall.logOut(device=>{
                //DO SOMETHING  
            }, (error)=>{
                //LOG ERROR 
            });

8.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.

8.1.2.1 Android

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 MainActivity extends CordovaActivity implements InboxAuthListener{

@Override
public JSONObject getAuthConfig() {
    return MY_JSON;
}

8.1.2.2 iOS

The token has a predetermined expiration date, once it has expired in our system, an event of type 'Protocol' will be launched, which will indicate said expiration and will have to return the configuration JSON. To collect the event, you have to implement it in the corresponding class, and override the following method:


class YOURCLASS: GetAuthConfig

func getAuthConfig() -> [AnyHashable : Any] {
        ...
        return YOUR_JSON
    }
@interface MainInboxProtocol: NSObject<GetAuthConfig>
@end

@implementation MainInboxProtocol

- (NSDictionary *)getAuthConfig{
    return YOUR_JSON;
}
@end

8.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.

8.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.


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.

8.2.2. Get notifications

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


window.plugins.indigitall.inbox.getInbox(inbox=>{
    //DO SOMETHING
},(error)=>{
    //LOG ERROR
});
8.2.2.1 Next page

Once the Inbox object has been obtained, we can request the following page, which is made with the following method:


window.plugins.indigitall.inbox.getNextPage(inbox=>{
         //DO SOMETHING
    },(error)=>{
         //LOG ERROR
         if (error.code == 410){
            //LOG NO MORE PAGES
        }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.

8.2.3. Get the information from a notification

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


window.plugins.indigitall.inbox.getInfoFromNotificationWithSendingId({sendingId:SENDING_ID},inboxNotification=>{
        //DO SOMETHING
},(error)=>{
        //LOG ERROR
});

8.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
window.plugins.indigitall.inbox.modifyStatusFromNotificationWithSendingId({sendingId:SENDING_ID, status:STATUS},inboxNotification=>{
    //DO SOMETHING  
},(error)=>{
    //LOG ERROR
});

//Massively modify
window.plugins.indigitall.inbox.massiveEditNotificationsWithSendingIdsList({sendingIdList:[SENDING_IDS],status:STATUS}, ()=>{
    //DO SOMETHING
},(error)=>{
    //LOG ERROR
});

8.2.5. Notifications status counters

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

window.plugins.indigitall.inbox.getMessageCount((counters)=>{
    //DO SOMETHING
},(error)=>{
    //LOG ERROR
});

9. Changelog

[2.15.0] - 04/2022

Added

  • Get data of received push

[2.14.0] - 03/2022

Added

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

[2.13.1] - 01/2022

Fixes

  • Add inAppWasShown method

[2.13.0] - 01/2022

Added

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

[2.12.1] - 11/2021

Fixes

  • Change apply plugin google services of build extra gradle

[2.12.0] - 10/2021

Added

  • Category field in Inbox notifications

[2.11.1] - 10/2021

Fixes

  • Device enable/disable

[2.11.0] - 10/2021

Added

  • Compatibility with Android 12
  • Customer Service

[2.10.0] - 09/2021

Added

  • InApp click control

[2.9.0] - 07/2021

Added

  • Update Huawei libs, native Android, iOS SDK's.

[2.8.0] - 05/2021

Added

  • New method to send custom event with data

    Fixes

  • Get Info from devices
  • If you don't implement HMS, you don't need to add anything to the gradle

[2.7.0] - 05/2021

Added

  • Hide inApp / popUp after a time configured in the console
  • InApp and popUp with rounded edges

[2.6.0] - 04/2021

Added

  • InApp action open app
  • Show InApp a number of times defined in console
  • PopUp rounded edges (android)

[2.5.5] - 02/2021

Fixes

  • Improve library implementation
  • Fix encrypted push

[2.5.4] - 01/2021

Fixes

  • Correctly display the body in android 6.0 and lower

[2.5.3] - 12/2020

Fixes

  • Add private cloud URL

[2.5.2] - 12/2020

Fixes

  • Stability in requests
  • Update UIWebView (Deprecated) by WKWebView

[2.5.1] - 11/2020

Fixes

  • Fix in plugin installation

[2.5.0] - 11/2020

Added

  • Persistent push

[2.4.5] - 11/2020

Fixes

  • Control if empty push object sent via API

[2.4.4] - 11/2020

Fixes

  • iOS request for wifi in the background

[2.4.3] - 11/2020

Fixes

  • PopUp error callback

[2.4.2] - 10/2020

Fixes

  • iOS: collect push data while the app is in the background

[2.4.1] - 09/2020

Fixes

  • Image in push on Huawei devices

[2.4.0] - 08/2020

Added

  • Inbox
  • Push with encrypted data

[2.3.0] - 07/2020

Added

  • Location integration with Harmony

[2.2.0] - 06/2020

Added

  • Integration with Harmony (Huawei Mobile Services)
  • Wallet Action
  • Native notifications.

[2.1.0] - 04/2020

Added

  • Customize popup icon
  • Wifi filter

[2.0.3] - 04/2020

Added

  • Update android

Fixes

  • Event visit

[2.0.2] - 04/2020

Fixes

  • Callback topicList
  • ExternalCode and CustomEvent methods
  • Subscription to topics with INtopic and strings

[2.0.1] - 03/2020

Added

  • Update iOS delegate methods

[2.0.0] - 03/2020

Added

  • Push pickup
  • InApp

Fixes

  • Custom Event
  • Location permissions