---
source_url: https://www.pubnub.com/docs/sdks/go/api-reference/mobile-push
title: Mobile Push Notifications API for Go SDK
updated_at: 2026-11-09T13:29:01.000Z
sdk_name: PubNub Go SDK
sdk_version: v10.2.0
description: Learn to manage push notifications with PubNub Go SDK. Integrate with FCM & APNs for efficient mobile push services.
---

# Mobile Push Notifications API for Go SDK

PubNub Go SDK, use the latest version: v10.2.0

Install:

```bash
go get github.com/pubnub/go/v10@v10.2.0
```

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

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/integrations/mobile-push-notifications/overview.md).

## 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://www.pubnub.com/docs/architecture/authentication/set-up-your-account.md#enable-the-features-your-app-calls).
:::

Enable mobile push notifications on a set of channels.

### Method(s)

```go
pn.AddPushNotificationsOnChannels().
        Channels([]string).
        DeviceIDForPush(string).
        PushType(PNPushTypeFCM|PNPushTypeAPNS2).
        Topic(string).
        Environment(PNPushEnvironment).
        QueryParam(map[string]string).
        Execute()
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| Channels | []string | Yes | n/a | Channels to enable for push notifications. |
| DeviceIDForPush | string | Yes | n/a | Device ID (push token). |
| PushType | PNPushTypeAPNS2PNPushTypeFCM | Yes | `Not set` | Accepted values: `PNPushTypeAPNS2`, `PNPushTypeFCM`. |
| Topic | string | Optional | `Not set` | APNs topic (bundle identifier). |
| Environment | PNPushEnvironment | Optional | `PNPushEnvironmentDevelopment` | APNs environment. Accepted values: `PNPushEnvironmentDevelopment`, `PNPushEnvironmentProduction`. |
| QueryParam | map[string]string | Optional | n/a | Map of query parameters to append to the API request. |

### Sample code

#### Add device to channel (FCM)

```go
// Replace with your package name (usually "main")
package pubnub_samples_test

import (
	"fmt"

	pubnub "github.com/pubnub/go/v10"
)

// Example_addChannelsToPushFCM demonstrates registering a device for FCM push notifications
func Example_addChannelsToPushFCM() {
	config := pubnub.NewConfigWithUserId(pubnub.UserId("demo-user"))
	config.SubscribeKey = "demo" // Replace with your subscribe key
	config.PublishKey = "demo"   // Replace with your publish key

	pn := pubnub.NewPubNub(config)

	// Add channels to push notifications for FCM (Firebase Cloud Messaging)
	_, status, err := pn.AddPushNotificationsOnChannels().
		Channels([]string{"notifications-channel", "alerts-channel"}). // Channels to enable for push
		DeviceIDForPush("device-fcm-token").                           // FCM device token
		PushType(pubnub.PNPushTypeFCM).                                // Use FCM push type
		Execute()

	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}

	if status.StatusCode == 200 {
		fmt.Println("FCM push notifications enabled for channels")
	}

	// Output:
	// FCM push notifications enabled for channels
}
```

#### Add device to channel (APNs2)

```go
// Replace with your package name (usually "main")
package pubnub_samples_test

import (
	"fmt"

	pubnub "github.com/pubnub/go/v10"
)

// Example_addChannelsToPushAPNS2 demonstrates registering a device for APNs2 push notifications
func Example_addChannelsToPushAPNS2() {
	config := pubnub.NewConfigWithUserId(pubnub.UserId("demo-user"))
	config.SubscribeKey = "demo" // Replace with your subscribe key
	config.PublishKey = "demo"   // Replace with your publish key

	pn := pubnub.NewPubNub(config)

	// Add channels to push notifications for APNs2 (Apple Push Notification service)
	_, status, err := pn.AddPushNotificationsOnChannels().
		Channels([]string{"notifications-channel", "alerts-channel"}).                       // Channels to enable for push
		DeviceIDForPush("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"). // APNs device token (64 hex chars)
		PushType(pubnub.PNPushTypeAPNS2).                                                    // Use APNs2 push type
		Topic("com.example.myapp").                                                          // APNs topic (bundle identifier)
		Environment(pubnub.PNPushEnvironmentDevelopment).                                    // APNs environment (development or production)
		Execute()

	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}

	if status.StatusCode == 200 {
		fmt.Println("APNs2 push notifications enabled for channels")
	}

	// Output:
	// APNs2 push notifications enabled for channels
}
```

### Returns

No payload is returned. Check `status.Error` on the status 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://www.pubnub.com/docs/architecture/authentication/set-up-your-account.md#enable-the-features-your-app-calls).
:::

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

### Method(s)

```go
pn.ListPushProvisions().
        DeviceIDForPush(string).
        PushType(PNPushTypeFCM|PNPushTypeAPNS2).
        Topic(string).
        Environment(PNPushEnvironment).
        QueryParam(map[string]string).
        Execute()
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| DeviceIDForPush | string | Yes | n/a | Device ID (push token). |
| PushType | PNPushTypeAPNS2PNPushTypeFCM | Yes | `Not set` | Accepted values: `PNPushTypeAPNS2`, `PNPushTypeFCM`. |
| Topic | string | Optional | `Not set` | APNs topic (bundle identifier). |
| Environment | PNPushEnvironment | Optional | `PNPushEnvironmentDevelopment` | APNs environment. Accepted values: `PNPushEnvironmentDevelopment`, `PNPushEnvironmentProduction`. |
| QueryParam | map[string]string | Optional | n/a | Map of query parameters to append to the API request. |

### Sample code

#### List channels for device (FCM)

```go
// Replace with your package name (usually "main")
package pubnub_samples_test

import (
	"fmt"

	pubnub "github.com/pubnub/go/v10"
)

// Example_listPushChannelsFCM demonstrates listing channels with push enabled for an FCM device
func Example_listPushChannelsFCM() {
	config := pubnub.NewConfigWithUserId(pubnub.UserId("demo-user"))
	config.SubscribeKey = "demo" // Replace with your subscribe key
	config.PublishKey = "demo"   // Replace with your publish key

	pn := pubnub.NewPubNub(config)

	// Setup: Register some channels first
	pn.AddPushNotificationsOnChannels().
		Channels([]string{"notifications-channel", "alerts-channel"}).
		DeviceIDForPush("device-fcm-token").
		PushType(pubnub.PNPushTypeFCM).
		Execute()

	// List all channels that have push notifications enabled for this FCM device
	response, status, err := pn.ListPushProvisions().
		DeviceIDForPush("device-fcm-token"). // FCM device token
		PushType(pubnub.PNPushTypeFCM).      // Use FCM push type
		Execute()

	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}

	if status.StatusCode == 200 {
		// Display the channels with push enabled
		if len(response.Channels) > 0 {
			fmt.Printf("Push enabled on %d channels\n", len(response.Channels))
		} else {
			fmt.Println("No channels with push enabled")
		}
	}

	// Output:
	// Push enabled on 2 channels
}
```

#### List channels for device (APNs2)

```go
// Replace with your package name (usually "main")
package pubnub_samples_test

import (
	"fmt"

	pubnub "github.com/pubnub/go/v10"
)

// Example_listPushChannelsAPNS2 demonstrates listing channels with push enabled for an APNs2 device
func Example_listPushChannelsAPNS2() {
	config := pubnub.NewConfigWithUserId(pubnub.UserId("demo-user"))
	config.SubscribeKey = "demo" // Replace with your subscribe key
	config.PublishKey = "demo"   // Replace with your publish key

	pn := pubnub.NewPubNub(config)

	// List all channels that have push notifications enabled for this APNs2 device
	response, status, err := pn.ListPushProvisions().
		DeviceIDForPush("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"). // APNs device token (64 hex chars)
		PushType(pubnub.PNPushTypeAPNS2).                                                    // Use APNs2 push type
		Topic("com.example.myapp").                                                          // APNs topic (bundle identifier)
		Environment(pubnub.PNPushEnvironmentDevelopment).                                    // APNs environment
		Execute()

	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}

	if status.StatusCode == 200 {
		// Display the channels with push enabled
		if len(response.Channels) > 0 {
			fmt.Printf("Push enabled on %d channels\n", len(response.Channels))
		} else {
			fmt.Println("No channels with push enabled")
		}
	}
}
```

### Returns

Returns `ListPushProvisionsRequestResponse` with:

| Method | Type | Description |
| --- | --- | --- |
| Channels | []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://www.pubnub.com/docs/architecture/authentication/set-up-your-account.md#enable-the-features-your-app-calls).
:::

Disable push notifications on selected channels.

### Method(s)

```go
pn.RemovePushNotificationsFromChannels().
        Channels([]string).
        DeviceIDForPush(string).
        PushType(PNPushTypeFCM|PNPushTypeAPNS2).
        Topic(string).
        Environment(PNPushEnvironment).
        QueryParam(map[string]string).
        Execute()
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| Channels | []string | Yes | n/a | Channels to disable for push notifications. |
| DeviceIDForPush | string | Yes | n/a | Device ID (push token). |
| PushType | PNPushTypeAPNS2PNPushTypeFCM | Yes | `Not set` | Accepted values: `PNPushTypeAPNS2`, `PNPushTypeFCM`. |
| Topic | string | Optional | `Not set` | APNs topic (bundle identifier). |
| Environment | PNPushEnvironment | Optional | `PNPushEnvironmentDevelopment` | APNs environment. Accepted values: `PNPushEnvironmentDevelopment`, `PNPushEnvironmentProduction`. |
| QueryParam | map[string]string | Optional | n/a | Map of query parameters to append to the API request. |

### Sample code

#### Remove device from channel (FCM)

```go
// Replace with your package name (usually "main")
package pubnub_samples_test

import (
	"fmt"

	pubnub "github.com/pubnub/go/v10"
)

// Example_removeChannelsFromPushFCM demonstrates removing specific channels from FCM push notifications
func Example_removeChannelsFromPushFCM() {
	config := pubnub.NewConfigWithUserId(pubnub.UserId("demo-user"))
	config.SubscribeKey = "demo" // Replace with your subscribe key
	config.PublishKey = "demo"   // Replace with your publish key

	pn := pubnub.NewPubNub(config)

	// Remove specific channels from FCM push notifications
	_, status, err := pn.RemovePushNotificationsFromChannels().
		Channels([]string{"alerts-channel"}). // Channels to remove from push
		DeviceIDForPush("device-fcm-token").  // FCM device token
		PushType(pubnub.PNPushTypeFCM).       // Use FCM push type
		Execute()

	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}

	if status.StatusCode == 200 {
		fmt.Println("Channels removed from FCM push notifications")
	}

	// Output:
	// Channels removed from FCM push notifications
}
```

#### Remove device from channel (APNs2)

```go
// Replace with your package name (usually "main")
package pubnub_samples_test

import (
	"fmt"

	pubnub "github.com/pubnub/go/v10"
)

// Example_removeChannelsFromPushAPNS2 demonstrates removing specific channels from APNs2 push notifications
func Example_removeChannelsFromPushAPNS2() {
	config := pubnub.NewConfigWithUserId(pubnub.UserId("demo-user"))
	config.SubscribeKey = "demo" // Replace with your subscribe key
	config.PublishKey = "demo"   // Replace with your publish key

	pn := pubnub.NewPubNub(config)

	// Remove specific channels from APNs2 push notifications
	_, status, err := pn.RemovePushNotificationsFromChannels().
		Channels([]string{"alerts-channel"}).                                                // Channels to remove from push
		DeviceIDForPush("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"). // APNs device token (64 hex chars)
		PushType(pubnub.PNPushTypeAPNS2).                                                    // Use APNs2 push type
		Topic("com.example.myapp").                                                          // APNs topic (bundle identifier)
		Environment(pubnub.PNPushEnvironmentDevelopment).                                    // APNs environment
		Execute()

	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}

	if status.StatusCode == 200 {
		fmt.Println("Channels removed from APNs2 push notifications")
	}

	// Output:
	// Channels removed from APNs2 push notifications
}
```

### Returns

No payload is returned. Check `status.Error` on the status object.

## 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://www.pubnub.com/docs/architecture/authentication/set-up-your-account.md#enable-the-features-your-app-calls).
:::

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

### Method(s)

```go
pn.RemoveAllPushNotifications().
        DeviceIDForPush(string).
        PushType(PNPushTypeFCM|PNPushTypeAPNS2).
        Topic(string).
        Environment(PNPushEnvironment).
        QueryParam(map[string]string).
        Execute()
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| DeviceIDForPush | string | Yes | n/a | Device ID (push token). |
| PushType | PNPushTypeAPNS2PNPushTypeFCM | Yes | `Not set` | Accepted values: `PNPushTypeAPNS2`, `PNPushTypeFCM`. |
| Topic | string | Optional | `Not set` | APNs topic (bundle identifier). |
| Environment | PNPushEnvironment | Optional | `PNPushEnvironmentDevelopment` | APNs environment. Accepted values: `PNPushEnvironmentDevelopment`, `PNPushEnvironmentProduction`. |
| QueryParam | map[string]string | Optional | n/a | Map of query parameters to append to the API request. |

### Sample code

#### Remove all mobile push notifications (FCM)

```go
// Replace with your package name (usually "main")
package pubnub_samples_test

import (
	"fmt"

	pubnub "github.com/pubnub/go/v10"
)

// Example_removeAllPushChannelsFCM demonstrates removing all channels from FCM push notifications
func Example_removeAllPushChannelsFCM() {
	config := pubnub.NewConfigWithUserId(pubnub.UserId("demo-user"))
	config.SubscribeKey = "demo" // Replace with your subscribe key
	config.PublishKey = "demo"   // Replace with your publish key

	pn := pubnub.NewPubNub(config)

	// Remove all push notification channels for this FCM device
	// This is useful when a user logs out or uninstalls the app
	_, status, err := pn.RemoveAllPushNotifications().
		DeviceIDForPush("device-fcm-token"). // FCM device token
		PushType(pubnub.PNPushTypeFCM).      // Use FCM push type
		Execute()

	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}

	if status.StatusCode == 200 {
		fmt.Println("All FCM push notifications removed")
	}

	// Output:
	// All FCM push notifications removed
}
```

#### Remove all mobile push notifications (APNs2)

```go
// Replace with your package name (usually "main")
package pubnub_samples_test

import (
	"fmt"

	pubnub "github.com/pubnub/go/v10"
)

// Example_removeAllPushChannelsAPNS2 demonstrates removing all channels from APNs2 push notifications
func Example_removeAllPushChannelsAPNS2() {
	config := pubnub.NewConfigWithUserId(pubnub.UserId("demo-user"))
	config.SubscribeKey = "demo" // Replace with your subscribe key
	config.PublishKey = "demo"   // Replace with your publish key

	pn := pubnub.NewPubNub(config)

	// Remove all push notification channels for this APNs2 device
	// This is useful when a user logs out or uninstalls the app
	_, status, err := pn.RemoveAllPushNotifications().
		DeviceIDForPush("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"). // APNs device token (64 hex chars)
		PushType(pubnub.PNPushTypeAPNS2).                                                    // Use APNs2 push type
		Topic("com.example.myapp").                                                          // APNs topic (bundle identifier)
		Environment(pubnub.PNPushEnvironmentDevelopment).                                    // APNs environment
		Execute()

	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}

	if status.StatusCode == 200 {
		fmt.Println("All APNs2 push notifications removed")
	}

	// Output:
	// All APNs2 push notifications removed
}
```

### Returns

No payload is returned. Check `status.Error` on the status object.

Last updated at: 2026-11-09T13:29:01.000Z
