Notification Center 5.2.0



To add the MoEngage Inbox SDK to your application, edit your application's pubspec.yaml file and add the below dependency to it:

 moengage_inbox: $latestVersion

Run flutter packages get to install the SDK.

Note: This plugin is dependent on moengage_flutter plugin. Make sure you have installed the moengage_flutter plugin as well. Refer to the doc for the same.

Android Installation


Once you install the Flutter Plugin add MoEngage's native Android SDK dependency to the Android project of your application.
Navigate to android/app/build.gradle. Add the MoEngage Android SDK's dependency in the dependencies block.

dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])

where $sdkVersion should be replaced by the latest version of the MoEngage SDK.

iOS Installation

In the case of iOS, the native dependency is part of the core SDK itself, so there is no need to include any additional dependency for supporting Notification Center.



Make sure to configure AppGroup ID in App Target and Set up Notification Service Extension in your iOS Project, for the SDK to save the received notifications.

Fetch Messages

To fetch all the inbox messages use fetchAllMessages() method as shown below, where you would get an instance of InboxData.

import 'package:moengage_inbox/inbox_data.dart';
import 'package:moengage_inbox/inbox_message.dart';
import 'package:moengage_inbox/moengage_inbox.dart';
MoEngageInbox _moEngageInbox = MoEngageInbox(YOUR_APP_ID);
InboxData data = await _moEngageInbox.fetchAllMessages();

InboxData Payload

InboxData will be received in the below format:

class InboxData {
  /// Native platform from which the callback was triggered.
  String platform;

  /// List of [InboxMessage]
  List messages;

class InboxMessage {
  /// internal identifier used by the SDK for storage.
  int id;

  /// Unique identifier for a message.
  String campaignId;

  /// Text content of the message. Instance of [TextContent]
  TextContent textContent;

  /// true if the message has been clicked by the user else false
  bool isClicked;

  /// Media content associated with the message.
  Media? media;

  /// List of actions to be executed on click.
  List action;

  /// Tag associated to the message.
  String tag;

  /// The time in which the message was received on the device.
  /// Format - ISO-8601 yyyy-MM-dd'T'HH:mm:ss'Z'
  String receivedTime;

  /// The time at which the message expiry.
  /// Format - ISO-8601 yyyy-MM-dd'T'HH:mm:ss'Z'
  String expiry;

  /// Complete message payload.
  Map<String, dynamic> payload;

class TextContent {
  /// Title string for the inbox message.
  String title;

  /// Message string for the inbox message.
  String message;

  /// Summary string for the inbox message.
  /// Note: This is present for Android Platform.
  String summary;

  /// Subtitle string for the inbox message.
  /// Note: This is present only for the iOS Platform.
  String subtitle;

class Media {
  /// Content type of the Media.
  MediaType mediaType;

  /// Url for the media content. Generally a http(s) url.
  String url;

class Action {
  /// ActionType - navigation
  ActionType actionType;

class NavigationAction extends Action {
  ///navigation type deepLink/richLanding/screenName
  NavigationType navigationType;

  String value;

  Map<String, dynamic> kvPair;

Get Unclicked Message Count

To obtain the unclicked messages count from the Inbox use getUnclickedCount() method as shown below:

MoEngageInbox _moEngageInbox = MoEngageInbox(YOUR_APP_ID);
int count = await _moEngageInbox.getUnClickedCount();

Track Message Clicks:

To track clicks on the messages inside your Inbox use trackMessageClicked() method as shown below:

MoEngageInbox _moEngageInbox = MoEngageInbox(YOUR_APP_D);
_moEngageInbox.trackMessageClicked(message);  //Pass the instance of InboxMessage here

Delete Message:

To delete a particular message from the list of messages use deleteMessage() method as shown below:

MoEngageInbox _moEngageInbox = MoEngageInbox(YOUR_APP_ID);
_moEngageInbox.deleteMessage(message);  //Pass the instance of InboxMessage here



Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?