App Inbox Integration

App inbox is essentially a screen within an app where all your notifications will be listed. App inbox offers you a way to make your push notifications persistent that users can refer back at any point.

👍

Read more about how app inbox feature works here

This guide will explain how to integrate app inbox.

Step 1: Complete the setup for CEE and SmartPush SDK

Go to Basic Setup to complete the basic setup of CEE SDK.

Go to Customer Engagement to complete the setup of SmartPush SDK, used for push notifications.

Step 2: Add CEE-AppInbox SDK dependency

Once you are done with Step 1, please add the CEE AppInbox dependency inside the app-level build.gradle file.

implementation 'com.netcore.android:smartech-appinbox:3.2.5'

Step 3: Setting up Proguard rules

Add the following lines in proguard-rules.pro to retain Smartech-appinbox files during the the proguard process.

# Smartech AppInbox SDK
-dontwarn com.netcore.android.smartechappinbox.**
-keep class com.netcore.android.smartechappinbox.**{*;}
-keep class * implements com.netcore.android.smartechappinbox.**.* {*;}
-keep class * extends com.netcore.android.smartechappinbox.**.* {*;}

Step 4: App Inbox UI Integration

CEE App Inbox SDK offers two options to create and manage the UI for app inbox screen for the app.

  • Default UI that has basic functionality to list notifications, swipe to delete, pull to refresh, filtering basis message category.
  • Custom UI that can you can create with SDK methods given below.

Default UI Integration

To add the AppInbox screen inside the app, you can either add it as a Fragment inside your app activity or open SDK's Appinbox activity.

You can use the method below to add the AppInbox fragment inside your FragmentActivity.

SmartechAppInbox smartechAppInbox = SmartechAppInbox.getInstance(new WeakReference<>(getApplicationContext()));
smartechAppInbox.displayAppInbox(activity,<layoutcontainerid>)
val smartechAppInbox = SmartechAppInbox.getInstance(WeakReference(applicationContext))
smartechAppInbox.displayAppInbox(activity,<layoutcontainerid>)

OR you can also use the below method to display SDK's AppInbox activity

SmartechAppInbox smartechAppInbox = SmartechAppInbox.getInstance(new WeakReference<>(getApplicationContext()));
smartechAppInbox.displayAppInbox(context);
val smartechAppInbox = SmartechAppInbox.getInstance(WeakReference(applicationContext))
smartechAppInbox.displayAppInbox(context)

Custom App Inbox UI Implementation

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

Get Inbox Messages

To fetch data from our Server, you can use the method below
This method accepts SMTAppInboxRequestBuilder as a parameter which is a builder class used to configure the request.
It has 4 fields.

  • Callback - this is an asynchronous call so we will provide data using the callback.
  • limit - Count of records of notification. E.g. 10
  • Category - Fetching data based on the app inbox categories provided by the user.
  • Type: It's an enum that has 3 values All, Latest, and Earliest.
ArrayList<String> categoryList = new ArrayList<>();
        categoryList.add("cat1");
        SmartechAppInbox smartechAppInbox = SmartechAppInbox.getInstance(new WeakReference<>(getApplicationContext()));
        SMTAppInboxRequestBuilder builder = new SMTAppInboxRequestBuilder.Builder(SMTInboxDataType.ALL)
                .setCallback(new SMTInboxCallback() {
                    @Override
                    public void onInboxProgress() {

                    }

                    @Override
                    public void onInboxSuccess(@Nullable List<SMTInboxMessageData> list) {

                    }

                    @Override
                    public void onInboxFail() {

                    }
                })
                .setCategory(categoryList).setLimit(10).build();

SmartechAppInbox smartechAppInbox = SmartechAppInbox.getInstance(new WeakReference<>(getApplicationContext()));
smartechAppInbox.getAppInboxMessages(builder);
val builder = SMTAppInboxRequestBuilder.Builder(SMTInboxDataType.ALL)
        builder.setCallback(object : SMTInboxCallback {
            override fun onInboxFail() {
            }

            override fun onInboxProgress() {
            }

            override fun onInboxSuccess(messages: MutableList<SMTInboxMessageData>?) {
            }
        })
        builder.setCategory(arrayListOf("cat1"))
        builder.setLimit(10).build();
val smartechAppInbox = SmartechAppInbox.getInstance(WeakReference(applicationContext))
smartechAppInbox.getAppInboxMessages(builder)

Fetching data from DB

You can use the below method to fetch the data from the database and it can be also used to show data in an offline state. This method accepts SMTAppInboxMessageType as a parameter.

SMTAppInboxMessageType is an enum and it has 3 values.
INBOX_MESSAGE - Get both read and unread messages from DB.
READ_MESSAGE- Get only read messages from DB.
UNREAD_MESSAGE - Get only unread messages from DB.

SmartechAppInbox smartechAppInbox = SmartechAppInbox.getInstance(new WeakReference<>(getApplicationContext()));
ArrayList<SMTInboxMessageData> messages = smartechAppInbox.getAppInboxMessages(SMTAppInboxMessageType.READ_MESSAGE)
val smartechAppInbox = SmartechAppInbox.getInstance(WeakReference(applicationContext))
val messages = smartechAppInbox.getAppInboxMessages(SMTAppInboxMessageType.READ_MESSAGE)

Category based data

Every AppInbox Message belongs to a specific category and we 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.

ArrayList<SMTInboxCategory> categoryList = smartechAppInbox.getAppInboxCategoryList();
val categoryList = smartechAppInbox.getAppInboxCategoryList()

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

ArrayList<String> categoryList = new ArrayList<String>();
categoryList.add("cat5");
ArrayList<SMTInboxMessageData> categoryFilteredData = smartechAppInbox.getAppInboxMessages(categoryList);
val categoryList = arrayListOf<String>("cat5")
val categoryFilteredData = smartechAppInbox.getAppInboxMessages(categoryList)

AppInbox Message Count

To show the count of all, read and unread messages, we can call the below method to get their respective count. This method accepts SMTAppInboxMessageType as a parameter.

SMTAppInboxMessageType is an enum and it has 3 values.
INBOX_MESSAGE - Get count of both read and unread messages from DB.
READ_MESSAGE- Get count of only read messages from DB.
UNREAD_MESSAGE - Get count of only unread messages from DB.

int count = smartechAppInbox.getAppInboxMessageCount(SMTAppInboxMessageType.INBOX_MESSAGE); int count = smartechAppInbox.getAppInboxMessageCount(SMTAppInboxMessageType.INBOX_MESSAGE);
val count = smartechAppInbox.getAppInboxMessageCount(SMTAppInboxMessageType.INBOX_MESSAGE)

Capturing App Inbox user events

You also need to send Viewed, Clicked and Dismissed events to SDK for every action performed on the AppInbox message by the user.

Viewed
Send 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.

smartechAppInbox.markMessageAsViewed(<"payload of AppInbox message">);
smartechAppInbox.markMessageAsViewed(<"payload of AppInbox message">);

Clicked
Onclick of AppInbox message, you need to send this event to SDK. This method takes 2 parameters that are deeplink and payload of AppInbox message.

smartechAppInbox.markMessageAsClicked("deeplink", <"payload of AppInbox message">);
smartechAppInbox.markMessageAsViewed(<"payload of AppInbox message">);

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.

smartechAppInbox.markMessageAsDismissed(<"payload of AppInbox message">);
smartechAppInbox.markMessageAsDismissed(<"payload of AppInbox message">);

Did this page help you?