Handling pagination

This guide covers the process loading and displaying chunks of conversation events at a time.

NOTE: A step-by-step tutorial to build a chat application is available here.

Given a Conversation you are already a Member of, you can download chunks (pages) of events existing within this conversation.

Load first page of events:

val conversationEventsListener = object : NexmoRequestListener<NexmoEventsPage> {
    override fun onSuccess(nexmoEventsPage: NexmoEventsPage?) {
        nexmoEventsPage?.pageResponse?.data?.let {
            val events = nexmoEventsPage?.data

    override fun onError(apiError: NexmoApiError) {
        Log.d("TAG", "Error: Unable to load conversation events ${apiError.message}")

conversation?.getEvents(100, NexmoPageOrder.NexmoMPageOrderAsc, null, conversationEventsListener)
NexmoRequestListener<NexmoEventsPage> conversationEventsListener = new NexmoRequestListener<NexmoEventsPage>() {
    public void onSuccess(@Nullable NexmoEventsPage eventsPage) {
        Collection<NexmoEvent> events = eventsPage.getData();

    public void onError(@NonNull NexmoApiError apiError) {
        Log.d("TAG", "Error: Unable to load conversation events %s", apiError.getMessage());

conversation.getEvents(100, NexmoPageOrder.NexmoMPageOrderAsc, null, conversationEventsListener);

After loading the first chunk of events you will get the reference to the current Nexmo Events Page. This reference allows to retrieve following event pages:

if(nexmoEventsPage.isNextPageExist) {
if(eventsPage.isNextPageExist()) {

Preceding pages can also be retrieved using a similar technique:

if(nexmoEventsPage.isPrevPageExist) {
if(eventsPage.isPrevPageExist()) {