iOS custom inbox mobile

Implement a custom inbox in your iOS Application

You can implement a custom inbox in your iOS application by implementing a custom inbox handler, which allows you to retrieve the Inbox Feed that you can custom-handle to meet your requirements.

This is done using the inboxListWithOffset method.

Retrieve inbox messages:

The inboxListWithOffset method allows you to asynchronously fetch a list of items from an inbox, starting at a specified offset, up to a specified limit, and then execute a callback function with the results.

+ (void)inboxListWithOffset:(NSUInteger)offset limit:(NSUInteger)limit callback:(XPInboxListCallback)callback

The following parameters are applied within the method:

  • offset: allows pagination
  • limit: number of inbox messages returned

callback: returns inbox list or error

XPInboxItem

The inboxListWithOffset method returns an array of XPInboxItem type.

XPush.inboxList(withOffset: 0, limit: 1) { (list, error) -> () in
  if (list != nil) {
      // handle list
  } else if (error != nil) {
      // handle error
  }
}
[XPush inboxListWithOffset:0 limit:10 callback:^(NSArray<XPInboxItem *> * _Nullable list, NSError * _Nullable error) {
        if (list != nil) {
            // handle list
        } else if (error != nil) {
            // handle error
        }
    }];

The parameters available for XPInboxItem are:

  • NSInteger identifier;
  • BOOL isOpened;
  • BOOL isClicked;
  • BOOL isDelivered;
  • NSNumber_ createTimestamp;
  • NSNumber_ expirationTimestamp;
  • XPInboxItemStyle_ style;
  • BOOL isCard;
  • XPMessageResponse_ response;

Delete an inbox message:

+(void)removeInboxMessage:(XPInboxItem*)message callback:(XPInboxBadgeCallback)callback

Used to delete an inbox message.

XPush.removeInboxMessage(item) { (badge) -> () in
          // reload inbox list
          // update inbox badge
      }

[XPush removeInboxMessage:inboxItem callback:^(NSInteger badge) {
                // reload inbox list
                // update inbox badge
            }];

Get inbox badge number:

+(NSInteger)getInboxBadge

Returns cached inbox number.

let badge: NSInteger = XPush.getInboxBadge()
NSInteger badge = [XPush getInboxBadge];

Report inbox message opened:

+(void)reportMessageOpened:(XPMessage _)message actionIdentifier:(NSString_)actionIdentifier

Used to mark an inbox message as opened on the platform.

XPush.reportMessageOpened(item.response.message, actionIdentifier: item.response.action.identifier)
[XPush reportMessageOpened:firstInboxItem.response.message actionIdentifier:firstInboxItem.response.action.identifier];

Report inbox message clicked:

+(void)reportMessageClicked:(XPMessage _)message actionIdentifier:(NSString_)actionIdentifier

Used to mark an inbox message as clicked on the platform. This also automatically marks an inbox message as opened.

XPush.reportMessageClicked(item.response.message, actionIdentifier: item.response.action.identifier)
[XPush reportMessageClicked:firstInboxItem.response.message actionIdentifier:firstInboxItem.response.action.identifier];