---
source_url: https://www.pubnub.com/docs/sdks/java/api-reference/mobile-push
title: Mobile Push Notifications API for Java SDK
updated_at: 2026-05-25T11:28:01.204Z
sdk_name: PubNub Java SDK
sdk_version: 6.4.5
---

> 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 API for Java SDK

PubNub Java SDK, use the latest version: 6.4.5

Install:

```bash
Add PubNub dependency to your build@6.4.5
```

:::warning Breaking changes in v9.0.0
PubNub Java SDK version 9.0.0 unifies the codebases for Java and [Kotlin](https://www.pubnub.com/docs/sdks/kotlin) SDKs, introduces a new way of instantiating the PubNub client, and changes asynchronous API callbacks and emitted [status events](https://www.pubnub.com/docs/sdks/java/status-events). These changes can impact applications built with previous versions (< `9.0.0`) of the Java SDK.
For more details about what has changed, refer to [Java/Kotlin SDK migration guide](https://www.pubnub.com/docs/sdks/kotlin/migration-guides/kotlin-v9-migration-guide).
:::

The Mobile Push Notifications feature connects native PubNub publishing to third-party push services. Supported services include Google Android FCM (Firebase Cloud Messaging) and Apple iOS APNs (Apple Push Notification service).

To learn more, read about [Mobile Push Notifications](https://www.pubnub.com/docs/general/push/send).

## Add a device to a push notifications channel

:::note Requires Mobile Push Notifications add-on
Enable Mobile Push Notifications for your key in the [Admin Portal](https://admin.pubnub.com/). See how to [enable add-on features](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-).
:::

Enable mobile push notifications on a set of channels.

### Method(s)

```java
pubnub.addPushNotificationsOnChannels()
    .pushType(PNPushType)
    .channels(List<String>)
    .deviceId(String)
    .topic(String)
    .environment(PNPushEnvironment)
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| pushType | PNPushType | Yes |  | Push notification type. Accepted values: `PNPushType.FCM` (Firebase Cloud Messaging), `PNPushType.APNS2` (Apple Push Notification service v2). |
| channels | List<String> | Yes |  | Channels to enable for push notifications. |
| deviceId | String | Yes |  | Device ID (push token). |
| topic | String | Optional |  | APNs topic (bundle identifier). Required for APNS2. |
| environment | PNPushEnvironment | Optional |  | APNs environment. Accepted values: `PNPushEnvironment.DEVELOPMENT`, `PNPushEnvironment.PRODUCTION`. Required for APNS2. |
| async | Consumer<Result> | Optional |  | `Consumer` of a `Result` of type `PNPushAddChannelResult`. |

### Sample code

:::tip Reference code
This example is a self-contained code snippet ready to be run. It includes necessary imports and executes methods with console logging. Use it as a reference when working with other examples in this document.
:::

#### Add device to channel

```java
import com.pubnub.api.PubNubException;
import com.pubnub.api.java.PubNub;
import com.pubnub.api.java.v2.PNConfiguration;
import com.pubnub.api.UserId;
import com.pubnub.api.enums.PNPushType;

import java.util.Arrays;

public class AddPushNotificationsOnChannelsApp {
    public static void main(String[] args) throws PubNubException {
        // Configure PubNub instance
        PNConfiguration.Builder configBuilder = PNConfiguration.builder(new UserId("demoUserId"), "demo");
        configBuilder.publishKey("demo");
        configBuilder.secure(true);

        PubNub pubnub = PubNub.create(configBuilder.build());

        // Add device to channels for push notifications
        pubnub.addPushNotificationsOnChannels()
                .pushType(PNPushType.FCM)
                .channels(Arrays.asList("ch1", "ch2", "ch3"))
                .deviceId("googleDevice")
                .async(result -> {
                    if (result.isSuccess()) {
                        System.out.println("Device added to channels for push notifications successfully.");
                    } else {
                        System.out.println("Failed to add device to channels.");
                    }
                });
    }
}
```

### Returns

No payload is returned. Check `result.isSuccess()` on the result object.

## List push notifications channels for a device

:::note Requires Mobile Push Notifications add-on
Enable Mobile Push Notifications for your key in the [Admin Portal](https://admin.pubnub.com/). See how to [enable add-on features](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-).
:::

Get all channels with push notifications for the specified push token.

### Method(s)

```java
pubnub.auditPushChannelProvisions()
    .pushType(PNPushType)
    .deviceId(String)
    .topic(String)
    .environment(PNPushEnvironment)
```

| Parameter | Description |
| --- | --- |
| `pushType` *Type: `PNPushType` | Push notification type. Accepted values: `PNPushType.FCM`, `PNPushType.APNS2`. |
| `deviceId` *Type: `String` | Device ID (push token). |
| `topic`Type: `String` | APNs topic (bundle identifier). Required for APNS2. |
| `environment`Type: `PNPushEnvironment` | APNs environment. Accepted values: `PNPushEnvironment.DEVELOPMENT`, `PNPushEnvironment.PRODUCTION`. Required for APNS2. |
| `async`Type: `Consumer<Result>` | `Consumer` of a `Result` of type `PNPushListProvisionsResult`. |

### Sample code

#### List channels for device

```java
pubNub.auditPushChannelProvisions()
        .deviceId("googleDevice")
        .pushType(PNPushType.FCM)
        .async(result -> { /* check result */ });
```

### Returns

Returns `PNPushListProvisionsResult` with:

| Method | Description |
| --- | --- |
| `getChannels()`Type: List`<String>` | Channels associated with push notifications. |

## Remove a device from push notifications channels

:::note Requires Mobile Push Notifications add-on
Enable Mobile Push Notifications for your key in the [Admin Portal](https://admin.pubnub.com/). See how to [enable add-on features](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-).
:::

Disable push notifications on selected channels.

### Method(s)

```java
pubnub.removePushNotificationsFromChannels()
    .pushType(PNPushType)
    .deviceId(String)
    .topic(String)
    .environment(PNPushEnvironment)
```

| Parameter | Description |
| --- | --- |
| `pushType` *Type: `PNPushType` | Push notification type. Accepted values: `PNPushType.FCM`, `PNPushType.APNS2`. |
| `channels` *Type: `List<String>` | Channels to disable for push notifications. |
| `deviceId` *Type: `String` | Device ID (push token). |
| `topic`Type: `String` | APNs topic (bundle identifier). Required for APNS2. |
| `environment`Type: `PNPushEnvironment` | APNs environment. Accepted values: `PNPushEnvironment.DEVELOPMENT`, `PNPushEnvironment.PRODUCTION`. Required for APNS2. |
| `async`Type: `Consumer<Result>` | `Consumer` of a `Result` of type `PNPushRemoveChannelResult`. |

### Sample code

#### Remove device from channel

```java
pubNub.removePushNotificationsFromChannels()
        .deviceId("googleDevice")
        .channels(Arrays.asList("ch1", "ch2", "ch3"))
        .pushType(PNPushType.FCM)
        .async(result -> { /* check result */ });
```

### Returns

No payload is returned. Check `result.isFailure()` on error or handle exceptions via `result.onFailure(...)`.

## Remove a device from all push notifications channels

:::note Requires Mobile Push Notifications add-on
Enable Mobile Push Notifications for your key in the [Admin Portal](https://admin.pubnub.com/). See how to [enable add-on features](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-).
:::

Disable push notifications from all channels registered for the specified push token.

### Method(s)

```java
pubnub.removeAllPushNotificationsFromDeviceWithPushToken()
    .pushType(PNPushType)
    .deviceId(String)
    .topic(String)
    .environment(PNPushEnvironment)
```

| Parameter | Description |
| --- | --- |
| `pushType` *Type: `PNPushType` | Push notification type. Accepted values: `PNPushType.FCM`, `PNPushType.APNS2`. |
| `deviceId` *Type: `String` | Device ID (push token). |
| `topic`Type: `String` | APNs topic (bundle identifier). Required for APNS2. |
| `environment`Type: `PNPushEnvironment` | APNs environment. Accepted values: `PNPushEnvironment.DEVELOPMENT`, `PNPushEnvironment.PRODUCTION`. Required for APNS2. |
| `async`Type: `Consumer<Result>` | `Consumer` of a `Result` of type `PNPushRemoveAllChannelsResult`. |

### Sample code

#### Remove all mobile push notifications

```java
pubNub.removeAllPushNotificationsFromDeviceWithPushToken()
        .deviceId("googleDevice")
        .pushType(PNPushType.FCM)
        .async(result -> { /* check result */ });
```

### Returns

No payload is returned. Check `result.isFailure()` on error or handle exceptions via `result.onFailure(...)`.

## Terms in this document

* **Channel** - A pathway for sending and receiving messages between devices, created automatically when you first use it, that can handle any number of users and messages for different communication needs, like 1-1 text chats, group conversations, and other data streaming.
* **PubNub** - PubNub is a real-time messaging platform that provides APIs and SDKs for building scalable applications. It handles the complex infrastructure of real-time communication, including: Message delivery and persistence, Presence detection, Access control, Push notifications, File sharing, Serverless processing with Functions and Events & Actions, Analytics and monitoring with BizOps Workspace, AI-powered insights with Illuminate.
* **Push token** - A device identifier issued by a push provider (APNs or FCM) used to register a device for receiving mobile push notifications.