---
source_url: https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/features/push-notifications
title: Mobile Push Notifications
updated_at: 2026-06-15T12:11:35.820Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Mobile Push Notifications

Notify online and offline users about appointments, updates, conversations, and more.

:::note Setup required
1. Enable **MOBILE PUSH NOTIFICATIONS** in [Admin Portal](https://admin.pubnub.com/) and configure **APPLE PUSH CREDENTIALS** or **FIREBASE CLOUD MESSAGING**.
2. [Configure Chat SDK](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/configuration#initialize-pubnub) to send/receive push notifications.
:::

## How to set up push notifications

Configure your app to receive notifications via [APNs](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns) (iOS) or [FCM](https://firebase.google.com/docs/cloud-messaging) (Android). See the [full documentation](https://www.pubnub.com/docs/general/push/send#configuration) for SDK-specific details.

1. Server-to-server setup: In Admin Portal, enable MOBILE PUSH NOTIFICATIONS and configure APPLE PUSH CREDENTIALS (APNs Authentication Token .p8 file) or FIREBASE CLOUD MESSAGING (Firebase Server Key).
2. Get device token: Register your app with APNs or FCM to get a unique device token for targeting push notifications. See Apple and Google docs.
3. iOS only: Create a bundle ID for your app.
4. Register channels: Associate the device token with PubNub channels. Messages on those channels trigger push notifications. Update registrations anytime during the app lifecycle.
5. Attach payload: Include provider-specific payload structure with each notification message.

## What's improved in Chat SDK

Chat SDK simplifies push notification setup:

### Simple configuration process

Configure push notifications once during [initialization](https://www.pubnub.com/docs/chat/kotlin-chat-sdk/build/configuration#initialize-pubnub) via `init()`. Separate options control sending and receiving.

### Easy methods for (un)registering channels

Simplified methods wrap [Kotlin SDK methods](https://www.pubnub.com/docs/sdks/kotlin/api-reference/mobile-push), eliminating repeated configuration:

* [Register channels](#register-selected-push-channels)
* [List registered channels](#list-all-push-channels)
* [Unregister selected](#unregister-selected-push-channels) or [all](#unregister-all-push-channels) channels

### Automatic payload creation

With `sendPushes` enabled, Chat SDK automatically attaches the correct payload structure to every message.

See this example:

```json
{
  "fcm": {
    "notification": {
      // message author - either the name or ID (if the name is missing)  
      "title": "John Doe",
      // content of the message
      "text": "Hello, this is a test notification!"
    }
  },
  "apns": {
    "configurations": [
      {
        "targets": [
          {
            // for example, "com.apple.iMovie"
            "topic": "com.domainname.applicationname"
          }
        ],
        "title": "John Doe",
        "text": "Hello, this is a test notification!",
        // default iOS sound for notifications
        "sound": "default",
        // name of the channel on which the message was published
        "subtitle": "Chat Room 1"
      }
    ]
  }
}
```

## Register selected push channels

Register channels to receive push notifications for new messages:

* `registerForPush()` - register a single channel (called on `Channel`)
* `registerPushChannels()` - register multiple channels (called on `Chat`)

### Method signature

These methods take the following parameters:

* registerForPush() - lets you register a device on a single channel 1channel.registerForPush(): PNFuture<PNPushAddChannelResult>
* registerPushChannels() - lets you register a device on multiple channels at once 1chat.registerPushChannels(channels: List<String>): PNFuture<PNPushAddChannelResult>

#### Input

As the `registerForPush()` method is invoked on the `Channel` object, it doesn't need to take any parameters. The channel the method is invoked on is the one registered.

The `registerPushChannels()` method takes the following parameters:

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| channels | List<String> | Yes |  | List of channels where you want your device to receive push notifications for sent messages. |

#### Output

| Type | Description |
| --- | --- |
| `PNFuture<PNPushAddChannelResult>` | Method returns no output data. |

### Sample code

* registerForPush() Receive push notifications for messages sent on the support channel. 1// register the "support" channel for push notifications2chat.getChannel("support").async { result ->3 result.onSuccess { channel ->4 // register this channel for push notifications5 channel.registerForPush().async { pushResult ->6 pushResult.onSuccess { pushAddChannelResult: PNPushAddChannelResult ->7 println("Successfully registered the 'support' channel for push notifications.")8 }.onFailure { throwable ->9 println("Failed to register the 'support' channel for push notifications.")10 throwable.printStackTrace()11 }12 }13 }.onFailure { throwable ->14 println("Failed to retrieve the 'support' channel.")15 throwable.printStackTrace()16 }17}
* registerPushChannels() Receive push notifications for messages sent on the support and inicident-management channels. 1// list of channels you want to register for push notifications2val channelsToRegister = listOf("support", "incident-management")3 4// register the list of channels for push notifications5chat.registerPushChannels(channelsToRegister).async { pushResult ->6 pushResult.onSuccess { pushAddChannelResult: PNPushAddChannelResult ->7 println("Successfully registered channels for push notifications: $channelsToRegister")8 }.onFailure { throwable ->9 println("Failed to register channels for push notifications: $channelsToRegister")10 throwable.printStackTrace()11 }12}

## List all push channels

Get all channels registered for push notifications on the device.

### Method signature

This method has the following signature:

```kotlin
chat.getPushChannels(): PNFuture<List<String>>
```

#### Input

This method doesn't take any parameters.

#### Output

| Type | Description |
| --- | --- |
| `PNFuture<List<String>>` | Returned list of all channels registered to receive push notifications on a given device. |

### Sample code

List all registered channels.

```kotlin
chat.getPushChannels().async { result ->
    result.onSuccess { channels ->
        println("Push notifications are registered for the following channels:")
        channels.forEach { channel ->
            println(channel)
        }
    }.onFailure { throwable ->
        println("Failed to retrieve push notification registered channels.")
        throwable.printStackTrace()
    }
}
```

## Unregister selected push channels

Stop receiving push notifications for specific channels:

* `unregisterFromPush()` - unregister a single channel (called on `Channel`)
* `unregisterPushChannels()` - unregister multiple channels (called on `Chat`)

### Method signature

These methods take the following parameters:

* unregisterFromPush() - lets you unregister a device from a single channel 1channel.unregisterFromPush(): PNFuture<PNPushRemoveChannelResult>
* unregisterPushChannels() - lets you unregister a device from multiple channels at once 1chat.unregisterPushChannels(channels: List<String>): PNFuture<PNPushRemoveChannelResult>

#### Input

As the `unregisterFromPush()` method is invoked on the `Channel` object, it doesn't need to take any parameters. The channel the method is invoked on is the one unregistered.

The `unregisterPushChannels()` method takes the following parameters:

| Parameter | Description |
| --- | --- |
| `channels` *Type: `List<String>`Default: n/a | List of channels where you want your device to unregister from receiving push notifications for sent messages. |

#### Output

| Type | Description |
| --- | --- |
| `PNFuture<PNPushRemoveChannelResult>` | Method returns no output data. |

### Sample code

* unregisterFromPush() Stop receiving push notifications for messages sent on the support channel. 1// Unregister the "support" channel for push notifications2chat.getChannel("support").async { result ->3 result.onSuccess { channel ->4 // Unregister this channel from push notifications5 channel.unregisterFromPush().async { pushResult ->6 pushResult.onSuccess { pushRemoveChannelResult: PNPushRemoveChannelResult ->7 println("Successfully unregistered the 'support' channel from push notifications.")8 }.onFailure { throwable ->9 println("Failed to unregister the 'support' channel from push notifications.")10 throwable.printStackTrace()11 }12 }13 }.onFailure { throwable ->14 println("Failed to retrieve the 'support' channel.")15 throwable.printStackTrace()16 }17}
* unregisterPushChannels() Stop receiving push notifications for messages sent on the support and inicident-management channels. 1// list of channels you want to unregister for push notifications2val channelsToUnregister = listOf("support", "incident-management")3 4// unregister the list of channels for push notifications5chat.unregisterPushChannels(channelsToUnregister).async { pushResult ->6 pushResult.onSuccess { pushRemoveChannelResult: PNPushRemoveChannelResult ->7 println("Successfully unregistered channels from push notifications: $channelsToUnregister")8 }.onFailure { throwable ->9 println("Failed to unregister channels from push notifications: $channelsToUnregister")10 throwable.printStackTrace()11 }12}

## Unregister all push channels

Disable push notifications for a device on all registered channels using `unregisterAllPushChannels()`.

### Method signature

This method has the following signature:

```kotlin
chat.unregisterAllPushChannels(): PNFuture<Unit>
```

#### Input

This method doesn't take any parameters.

#### Output

| Type | Description |
| --- | --- |
| `PNFuture<Unit>` | Method returns no output data. |

### Sample code

Disable push notifications on all registered channels.

```kotlin
// unregister all channels for push notifications
chat.unregisterAllPushChannels().async { pushResult ->
    pushResult.onSuccess { 
        println("Successfully unregistered all channels from push notifications")
    }.onFailure { throwable ->
        println("Failed to unregister all channels from push notifications")
        throwable.printStackTrace()
    }
}
```