PushChannel

The PushChannel object lets a device subscribe to and unsubscribe from push notifications published on a channel, and list the push subscriptions on that channel. Access it via channel.push.

JavaScript

1

const pushChannel = channel.push;

Subscribe this device

pushChannel.subscribeDevice(): Promise<void>

Subscribe the local device to the channel's push notifications.

JavaScript

1

await channel.push.subscribeDevice();

Returns

Promise<void>

Returns a promise. The promise is fulfilled when the subscription has been created, or rejected with an ErrorInfo object.

Subscribe all devices with this clientId

pushChannel.subscribeClient(): Promise<void>

Subscribe all devices associated with this client's clientId to the channel's push notifications.

JavaScript

1

await channel.push.subscribeClient();

Returns

Promise<void>

Returns a promise. The promise is fulfilled when the subscription has been created, or rejected with an ErrorInfo object.

Unsubscribe this device

pushChannel.unsubscribeDevice(): Promise<void>

Unsubscribe the local device from the channel's push notifications.

JavaScript

1

await channel.push.unsubscribeDevice();

Returns

Promise<void>

Returns a promise. The promise is fulfilled when the subscription has been removed, or rejected with an ErrorInfo object.

Unsubscribe all devices with this clientId

pushChannel.unsubscribeClient(): Promise<void>

Unsubscribe all devices associated with this client's clientId from the channel's push notifications.

JavaScript

1

await channel.push.unsubscribeClient();

Returns

Promise<void>

Returns a promise. The promise is fulfilled when the subscriptions have been removed, or rejected with an ErrorInfo object.

List subscriptions on this channel

pushChannel.listSubscriptions(params?: Record<string, string>): Promise<PaginatedResult<PushChannelSubscription>>

Lists push subscriptions on the channel by querying the REST API's list channel subscriptions endpoint. These subscriptions can be a list of client (clientId) subscriptions, device (deviceId) subscriptions, or a combination of both. This method requires clients to have the Push Admin capability.

JavaScript

1

const subscriptions = await channel.push.listSubscriptions({ deviceId: '<device-id>' });

Parameters

The listSubscriptions() method takes the following parameters:

paramsoptionalRecord<String, String>
An object containing key-value pairs to filter subscriptions by. Can contain clientId, deviceId, or a combination of both, and a limit on the number of subscriptions returned (up to 1,000).

Returns

Promise<PaginatedResult<PushChannelSubscription>>

Returns a promise. The promise is fulfilled with a PaginatedResult containing an array of PushChannelSubscription objects, which supports pagination using its next and first methods, or rejected with an ErrorInfo object.

channelString
The channel that this push notification subscription is associated with.
deviceIdString or Undefined
The device with this identifier is linked to this channel subscription. When present, clientId is never present.
clientIdString or Undefined
Devices with this client identifier are included in this channel subscription. When present, deviceId is never present.