Unity App Inbox

App Inbox

The CleverTap Unity SDK provides the capability to create App Inbox notifications for your users.
You can use the App Inbox provided by CleverTap or create your own.
You can design App Inbox notifications right from the dashboard.

Android

On the Android side, add the following inbox dependencies in your app's build.gradle.

//MANDATORY for App Inbox

implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.viewpager:viewpager:1.0.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.github.bumptech.glide:glide:4.12.0'

//Optional ExoPlayer Libraries for Audio/Video Inbox Messages. Audio/Video messages will be dropped without these dependencies

implementation 'com.google.android.exoplayer:exoplayer:2.15.1'
implementation 'com.google.android.exoplayer:exoplayer-hls:2.15.1'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.15.1'

Unity/C#

Initializing the Inbox provides a callback to two methods inboxDidInitialize() and inboxMessagesDidUpdate()

CleverTapBinding.InitializeInbox();

Configure styling and show the inbox by following the steps below:

  1. Customize the config object and call the Inbox in the inboxDidInitialize() method
  2. Call this method on the button click which opens the CleverTap Inbox for your App
//returns callback for InitializeInbox
void CleverTapInboxDidInitializeCallback()
{
    Dictionary<string, object> StyleConfig = new Dictionary<string, object>();
        StyleConfig.Add('navBarTitle': 'My App Inbox');
        StyleConfig.Add('navBarTitleColor': '#FF0000');
        StyleConfig.Add('navBarColor': '#FFFFFF',);
        StyleConfig.Add('inboxBackgroundColor': '#AED6F1');
        StyleConfig.Add('backButtonColor': '#00FF00');
        StyleConfig.Add('unselectedTabColor': '#0000FF');
        StyleConfig.Add('selectedTabColor': '#FF0000');
        StyleConfig.Add('noMessageText': 'No message(s)');
        StyleConfig.Add('navBarTitle': 'My App Inbox');
        StyleConfig.Add('noMessageTextColor': '#FF0000');

        CleverTapBinding.ShowAppInbox(StyleConfig);
}

When a new inbox message arrives, the SDK provides the inboxMessagesDidUpdate() callback

void CleverTapInboxMessagesDidUpdateCallback()
{
    Debug.Log("unity received inbox messages updated");
}

Create your own App Inbox

You can choose to create your own App Inbox by calling the following APIs:

Initialize App Inbox

CleverTapBinding.InitializeInbox();

Show App Inbox

Dictionary<string, object> StyleConfig = new Dictionary<string, object>();
StyleConfig.Add('navBarTitle': 'My App Inbox');
StyleConfig.Add('navBarTitleColor': '#FF0000');
StyleConfig.Add('navBarColor': '#FFFFFF',);
StyleConfig.Add('inboxBackgroundColor': '#AED6F1');
StyleConfig.Add('backButtonColor': '#00FF00');
StyleConfig.Add('unselectedTabColor': '#0000FF');
StyleConfig.Add('selectedTabColor': '#FF0000');
StyleConfig.Add('noMessageText': 'No message(s)');
StyleConfig.Add('navBarTitle': 'My App Inbox');
StyleConfig.Add('noMessageTextColor': '#FF0000');

CleverTapBinding.ShowAppInbox(StyleConfig);

Get Total Inbox Message Count

CleverTapBinding.GetInboxMessageCount();

Get Total Inbox Unread Count

CleverTapBinding.GetInboxMessageUnreadCount();

Get All Inbox Messages

CleverTapBinding.GetAllInboxMessages();

Get All Inbox Unread Messages

CleverTapBinding.GetInboxMessageUnreadCount();

Get Inbox Message for the given message-id

CleverTapBinding.GetInboxMessageForId("messageId");

Delete Message for the given message-id

CleverTapBinding.DeleteInboxMessageForID("messageId");

Mark Message as Read for the given message-id

CleverTapBinding.MarkReadInboxMessageForID("messageId");

Raise Notification Viewed event for Inbox Message
Message-id must be a string value.

CleverTapBinding.RecordInboxNotificationViewedEventForID("messageId");

Raise Notification Clicked event for Inbox Message
Message-id must be a string value.

CleverTapBinding.RecordInboxNotificationViewedEventForID("messageId");