# Usage

The `bird.appinbox` is the main entry point for app inbox in Bird client SDKs. Through which you can do the following:

* Get messages
* Listen to incoming messages
* Mark message as read

## Get messages

{% tabs %}
{% tab title="Android" %}

<pre class="language-kotlin"><code class="lang-kotlin"><strong>// getAppInboxMessages() returns a flow which you can gradually consume
</strong><strong>bird?.appInbox?.getAppInboxMessages()?.collect { message ->
</strong><strong>  println("Message: $message")
</strong><strong>}
</strong><strong>
</strong><strong>// or you can consume the whole flow into one list
</strong><strong>val allMessages = bird?.appInbox?.getAppInboxMessages()?.toList()
</strong><strong>
</strong></code></pre>

{% endtab %}
{% endtabs %}

## Listen to incoming messages

App inbox messages will arrive in real-time when the client application is opened. You can listen to incoming messages as shown in this example

{% tabs %}
{% tab title="Android" %}

<pre class="language-kotlin"><code class="lang-kotlin"><strong>// incoming is a Channel&#x3C;AppInboxMessage> through which you can
</strong><strong>// listen to incoming messages
</strong><strong>bird?.appInbox?.incoming?.consumeEach { message ->
</strong><strong>  println("Message: $message")
</strong><strong>}
</strong><strong>
</strong></code></pre>

{% endtab %}
{% endtabs %}

## Mark message as read

Each message has a `readAt` field to indicate whether is read or unread and when the message was read. You can mark a message as read by calling `bird.appinbox.markMessageRead(message)`.

{% tabs %}
{% tab title="Android" %}

<pre class="language-kotlin"><code class="lang-kotlin"><strong>// markMessageRead() marks the message as read
</strong><strong>bird?.appInbox?.markMessageRead(message)
</strong><strong>
</strong></code></pre>

{% endtab %}
{% endtabs %}
