AppInbox Integration

The App inbox is feature within mobile applications provide you with a centralized location to access and manage the notifications that are listed. App inbox offers you a way to make your push notifications persistent that users can refer back at any point.

To enable this feature, reach out to your Account Manager. For more information, refer to App Inbox.

Integration Steps

To integrate AppInbox into your mobile application, follow these steps:

For Android SDK

Integrate AppInbox functionality into your Android application by following these steps:

  1. Define Latest SDK version: Add the version line to your gradle.properties.
// Version of smartech push SDK to use with Cordova
SMARTECH_APPINBOX_SDK_VERSION=<<appinbox_sdk_android_version>>
  1. Integrate the latest Netcore CE SDK by changing the app-level build.gradle.
api "com.netcore.android:smartech-appinbox:${SMARTECH_APPINBOX_SDK_VERSION}"

For Cordova SDK

Integrate AppInbox functionality into your Cordova application by following these steps:

  1. Complete the setup for Netcore CE and SmartPush SDK for Cordova.

Refer to Basic Setup to complete the basic setup of CEE SDK. Refer to Customer Engagement to complete the setup of SmartPush SDK for push notifications.

  1. Install the Netcore CE Cordova Smartech AppInbox plugin by running the below command from your project directory.
cordova plugin add smartech-appinbox-cordova --save
  1. Initialize the SDK to the Netcore CE Cordova library in your JavaScript file.
const SmartechAppInboxCordova = window.plugins.SmartechAppInboxCordova;
import SmartechAppInboxCordova from 'smartech-appinbox-cordova';
  1. App Inbox SDK offers two options to create and manage the UI for the app's inbox screen.

Custom App Inbox UI Implementation

You can create a custom Inbox UI using our SDK method to fetch and display data inside your app.

Get Inbox Messages

To fetch data of app inbox messages from our server, you can use the optional methods below.

  • messageLimit : Count of records of notification. Example: 10
  • categoryList : Fetching data based on the app inbox categories provided by the user.
  • messageType: It's an integer that has three values :all, latest, and earliest.
SmartechAppInboxCordova.getAppInboxMessagesByApiCall(messageLimit, messageType, categoryList, (result) => {
    console.log(JSON.stringify(array));
}, (error) => {
    console.log("error:" + error);
})

Fetching data from DB

You can use the below method to fetch data from the database and show it in an offline state.

//INBOX_MESSAGE = 1, READ_MESSAGE = 2, UNREAD_MESSAGE =3

SmartechAppInboxCordova.getAppInboxMessages(messageType, (result) => {
                
});

Category based data

Every AppInbox message belongs to a specific category. You can use this data to create a dropdown on the menu to display the list of available categories to users.

The below method can be used to get a list of available categories.

SmartechAppInboxCordova.getAppInboxCategoryList((categoryList) => {
             
 };

The below method can be used to filter the AppInbox messages list based on the category selected by the user. It takes an array of category objects as a parameter.

  • categoryList : Fetching data based on the app inbox categories provided by the user. This is optional method.
 SmartechAppInboxCordova.getAppInboxMessagesWithCategory(categoryArray, (appInboxMessages: object[]) => {
  console.log(JSON.stringify(appInboxMessages));
 }, (error: Error) => {             
 });

AppInbox Message Count

To show the count of all, read, and unread messages, you can call the below method to get their respective count.
This method accepts type (number) as a parameter.

It could be of three types.

  • INBOX_MESSAGE: Get the count of all messages from database.
  • READ_MESSAGE: Get count of only read messages from database.
  • UNREAD_MESSAGE: Get count of only unread messages from database.
// INBOX_MESSAGE = 1, READ_MESSAGE = 2, UNREAD_MESSAGE =3

SmartechAppInbox.getAppInboxMessageCount(SmartechAppInbox.INBOX_MESSAGE, (count) => {
                
});

AppInbox Message Events

When users interact with messages in the AppInbox, it's essential to capture these actions for analytics and tracking purposes. You need to send Viewed, Clicked, and Dismissed events to SDK for every action performed on the AppInbox message. The following events should be handled:

Viewed Event:

Trigger this event once the AppInbox message is visible to the user and It should be sent only one time for each AppInbox message. This method accepts the payload of the AppInbox message as a parameter.

 SmartechAppInboxCordova.markMessageAsViewed(objItem);

Clicked Event:

Trigger this event when a user clicks on an AppInbox message. Provide the deeplink and trid of the message as parameters.

SmartechAppInboxCordova.markMessageAsClicked(trid, deeplink) //deeplink and trid of the Appinboxmessage

Dismissed

You can use this method to mimic the feature of swipe to delete the messages from your Recyclerview. You need to manually remove the message from the recycler view and next time when you will fetch the data from the DB, this message will be not present. This method accepts payload of the AppInbox messages.

SmartechAppInboxCordova.markMessageAsDismissed(objAppInboxItem, (status) => {
   if (status) {
       // If true, Item is dismissed.

   }
});

CopyMessageAsClicked

Trigger this event when a user user clicks on the Copy action button of an AppInbox message. Provide the action button payload and trid of the message as parameters.

 SmartechAppInboxCordova.copyMessageAsClicked(itemObj, trid);

📘

Demo Project on Github

Click here, to check the demo project on Github.