Inbox

Basic configuration

This feature lets you store targeted messages inside a Inbox within your app, in a similar way that a mailbox stores emails. With this Inbox, your users can retrieve messages over time, browse through the list of inbox messages and interact with them. Inbox messages are a good complement to Push Notifications or In-App messages.

These Inbox messages can be a text, a webpage, a landing page, and more... with or without buttons.

Note that Inbox messages are independent from Push Notifications. You can send Inbox messages which were never sent as Push Notifications, and Push Notifications will not automatically be displayed in your Inbox.

Please note that inbox messages are not impacted by the Opt-in/Opt-out system.

This means that a user can be targeted for inbox messages event if this one is Opt-out to Push Notifications.

Inside the Accengage dashboard, when setting up a Push Notification, there is a shortcut to set up the equivalent of your push as an Inbox message.

The Inbox messages and buttons interact directly with the Accengage SDK.

You can for instance send a message with a button which will trigger an event, a URL scheme, or display a banner/interstitial when the user clicks on the message.

With Accengage Inbox you can:

  • Obtain messages and display them in your own template
  • Update messages status on Accengage Servers (Read/Unread/Archived)
  • Track message events like displaying, opening and button click for statistic purpose

Sample code

If you want to use this feature, Accengage servers will send all the message information to your app but you will need to create the interface yourself.

A complete sample project containing an Inbox implementation is available here. You can use it as a starting point and then adapt the interface to your needs.

Get Messages

Use the following method to get some messages
You will need an async callback block to be notified when a message is received. Here is an example of how to define it:

Objective-C:

[BMA4SInBox obtainMessagesWithCompletionHandler:^(BMA4SInBoxLoadingResult result, BMA4SInBox *inbox) {
    // Messages were downloaded, are ready and contained in a BMA4SInbox Object.
}];

List Messages

Now that we have our inbox object filled with messages, we can display them in a UITableView. In this example, we will associate a UITableViewCell for each message.

Do not forget to track the display of your message.

Objective-C:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  // initialize your cell
  UITableViewCell *cell;
  NSUInteger index = indexPath.row;

  // we obtain the messages
  [inbox obtainMessageAtIndex:index loaded:^(BMA4SInBoxMessage *message, NSUInteger requestedIndex) {

    if (index == requestedIndex) {
      // we check if the message is already marked as displayed
      if (!message.isDisplayed) {
        // we mark the message as displayed...
        [message markAsDisplayed];
        // .. and we track the display
        [message trackDisplay];
      }

      // setup your cell with message title, sender name...

    }
  } onError:^(NSUInteger requestedIndex) {
    NSLog(@"Error loading message #%lu", (unsigned long)requestedIndex);
  }];

  return cell;
}

Message interactions

Now that we have downloaded and displayed our messages, we will allow our user to interact with them.
For example, if you display a message in a UITableView, you may want to provide the user with some interaction if he touches a table row.
You will need to give the message the user interacted with to the SDK.
According to the message format, the SDK can either start a predefined action or give it back to you to be displayed.

Do not forget to track the message opening when the user interacts with the message.

Objective-C:

// our user interacts with row a indexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // obtain message as usual
    [inbox obtainMessageAtIndex:indexPath.row loaded:^(BMA4SInBoxMessage *message, NSUInteger requestedIndex) {
        // track the message opening
        [message trackOpening];
        // Call message 'interactWithDisplayHandler' method to hand the message to the SDK
        [message interactWithDisplayHandler:^(BMA4SInBoxMessage* message, BMA4SInBoxMessageContent *content) {
            // If this block is called back, I will need to display message content to the user myself.
            // Just create a view controller for display and push it on navigation stack
        }];
    }
    onError:^(NSUInteger requestedIndex){
        // Silently ignore error
    }];
}

Tracking

The SDK provides three methods that allow you to track Inbox related events.

To track the message opening use the following BMA4SInboxMessage method:

Objective-C:

- (void)trackOpening;

To track the message display use the following BMA4SInboxMessage method:

Objective-C:

- (void)trackDisplay;

To track the button click use the following BMA4SInboxButton method:

Objective-C:

- (void)trackClick;

Advanced configuration

Work with Message Buttons

A message content can have some buttons. Here is an example of how to display and interact with these them.

Do not forget to track the message button click.

Objective-C:

// step 1: setup buttons
for(int i = 0; i < [self.content.buttons count]; ++i) {
    // obtain button description
    BMA4SInBoxButton* btn = [self.content.buttons objectAtIndex:i];
    // create button, customize title and bind events
    UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button setTitle:btn.title forState:UIControlStateNormal];
    [button setFrame:CGRectMake(0, 5, 50, 30)];
    [button addTarget:self action:@selector(onButtonTouched:) forControlEvents:UIControlEventTouchUpInside];
    [button setTag:i];
    // add the button to the layout
    [self.scrollView addSubview:button];
}

// step 2: handle button clicks
- (void)onButtonTouched:(id)sender {
    NSInteger tag = [sender tag];
    BMA4SInBoxButton *button = self.content.buttons[tag];

    // we track the click on the message button
    [button trackClick];
    // call 'interact' method on appropriate BMA4SInBoxButton object
    [button interact];
}

Update message status

You can change the status of a message, by using the following methods:

Objective-C:

//Marks a message as displayed
[message markAsDisplayed];
[message markAsUndisplayed];

// Marks a message as read or unread
[message markAsRead];
[message markAsUnread];

// Archive or Unarchive a message
[message archive];
[message unarchive];