Share via


NotificationHubsClient class

This represents a client for Azure Notification Hubs to manage installations and send messages to devices.

Constructors

NotificationHubsClient(string, string, NotificationHubsClientOptions)

Creates a new instance of the NotificationClient with a connection string, hub name and options.

Methods

beginSubmitNotificationHubJob(NotificationHubJob, PolledOperationOptions)

Submits a Notification Hub job and creates a poller to poll for results.

cancelScheduledNotification(string, OperationOptions)

Cancels the scheduled notification with the given notification ID.

createOrUpdateInstallation(Installation, OperationOptions)

Creates or overwrites an installation to a Notification Hub.

createOrUpdateRegistration(RegistrationDescription, OperationOptions)

Creates or updates a registration.

createRegistration(RegistrationDescription, OperationOptions)

Creates a new registration. This method generates a registration ID, which you can subsequently use to retrieve, update, and delete this registration.

createRegistrationId(OperationOptions)

Creates a new registration ID.

deleteInstallation(string, OperationOptions)

Deletes an installation from a Notification Hub.

deleteRegistration(string, EntityOperationOptions)

Deletes a registration with the given registration ID.

getFeedbackContainerUrl(OperationOptions)

Retrieves an Azure Storage container URL. The container has feedback data for the notification hub. The caller can then use the Azure Storage Services SDK to retrieve the contents of the container.

getInstallation(string, OperationOptions)

Gets an Azure Notification Hub installation by the installation ID.

getNotificationHubJob(string, OperationOptions)

Gets a Notification Hub Job by the ID.

getNotificationOutcomeDetails(string, OperationOptions)

Retrieves the results of a send operation. This can retrieve intermediate results if the send is being processed or final results if the Send* has completed. This API can only be called for Standard SKU and above.

getRegistration(string, OperationOptions)

Gets a registration by the given registration ID.

listNotificationHubJobs(OperationOptions)

Gets all Notification Hub Jobs for this Notification Hub.

listRegistrations(RegistrationQueryLimitOptions)

Gets all registrations for the notification hub with the given query options.

listRegistrationsByChannel(RegistrationChannel, RegistrationQueryLimitOptions)

Gets all registrations for the notification hub with the given device information and options.

listRegistrationsByTag(string, RegistrationQueryLimitOptions)

Lists all registrations with the matching tag.

scheduleBroadcastNotification(Date, Notification, OperationOptions)

Schedules a push notification to all devices at the specified time. NOTE: This is only available in Standard SKU Azure Notification Hubs.

scheduleNotification(Date, Notification, ScheduleNotificationOptions)

Schedules a push notification to devices that match the given tags or tag expression at the specified time. NOTE: This is only available in Standard SKU Azure Notification Hubs.

sendBroadcastNotification(Notification, BroadcastSendNotificationOptions)

Sends push notifications to devices all devices.

sendNotification(Notification, DirectSendNotificationOptions | SendNotificationOptions)

Sends push notifications to devices that match the given tags or tag expression.

submitNotificationHubJob(NotificationHubJob, OperationOptions)

Submits a Notification Hub Job. Note this is available to Standard SKU namespace and above.

updateInstallation(string, JsonPatch[], OperationOptions)

Updates an installation using the JSON-Patch standard in RFC6902.

updateRegistration(RegistrationDescription, OperationOptions)

Updates an existing registration.

Constructor Details

NotificationHubsClient(string, string, NotificationHubsClientOptions)

Creates a new instance of the NotificationClient with a connection string, hub name and options.

new NotificationHubsClient(connectionString: string, hubName: string, options?: NotificationHubsClientOptions)

Parameters

connectionString

string

The Notification Hub Access Policy connection string.

hubName

string

The name of the Azure Notification Hub.

options
NotificationHubsClientOptions

Options for configuring the Azure Notification Hubs client.

Method Details

beginSubmitNotificationHubJob(NotificationHubJob, PolledOperationOptions)

Submits a Notification Hub job and creates a poller to poll for results.

function beginSubmitNotificationHubJob(notificationHubJob: NotificationHubJob, options?: PolledOperationOptions): Promise<NotificationHubJobPoller>

Parameters

notificationHubJob
NotificationHubJob

The Notification Hub import/export job to start.

options
PolledOperationOptions

The operation options.

Returns

A poller which can be called to poll until completion of the job.

cancelScheduledNotification(string, OperationOptions)

Cancels the scheduled notification with the given notification ID.

function cancelScheduledNotification(notificationId: string, options?: OperationOptions): Promise<NotificationHubsResponse>

Parameters

notificationId

string

The notification ID from the scheduled notification.

options
OperationOptions

The operation options.

Returns

A notification hub response with correlation ID and tracking ID.

createOrUpdateInstallation(Installation, OperationOptions)

Creates or overwrites an installation to a Notification Hub.

function createOrUpdateInstallation(installation: Installation, options?: OperationOptions): Promise<NotificationHubsResponse>

Parameters

installation
Installation

The installation to create or overwrite.

options
OperationOptions

Configuration options for the create or update installation operation.

Returns

A NotificationHubResponse with the tracking ID, correlation ID and location.

createOrUpdateRegistration(RegistrationDescription, OperationOptions)

Creates or updates a registration.

function createOrUpdateRegistration(registration: RegistrationDescription, options?: OperationOptions): Promise<RegistrationDescription>

Parameters

registration
RegistrationDescription

The registration to create or update.

options
OperationOptions

The operation options.

Returns

The created or updated registration description.

createRegistration(RegistrationDescription, OperationOptions)

Creates a new registration. This method generates a registration ID, which you can subsequently use to retrieve, update, and delete this registration.

function createRegistration(registration: RegistrationDescription, options?: OperationOptions): Promise<RegistrationDescription>

Parameters

registration
RegistrationDescription

The registration to create.

options
OperationOptions

Options for creating a new registration.

Returns

The newly created registration description.

createRegistrationId(OperationOptions)

Creates a new registration ID.

function createRegistrationId(options?: OperationOptions): Promise<string>

Parameters

options
OperationOptions

The options for creating a new registration ID.

Returns

Promise<string>

The newly created registration ID.

deleteInstallation(string, OperationOptions)

Deletes an installation from a Notification Hub.

function deleteInstallation(installationId: string, options?: OperationOptions): Promise<NotificationHubsResponse>

Parameters

installationId

string

The installation ID of the installation to delete.

options
OperationOptions

Configuration options for the installation delete operation.

Returns

A NotificationHubResponse with the tracking ID, correlation ID and location.

deleteRegistration(string, EntityOperationOptions)

Deletes a registration with the given registration ID.

function deleteRegistration(registrationId: string, options?: EntityOperationOptions): Promise<NotificationHubsResponse>

Parameters

registrationId

string

The registration ID of the registration to delete.

options
EntityOperationOptions

The options for delete operations including the ETag

Returns

A NotificationHubResponse with the tracking ID, correlation ID and location.

getFeedbackContainerUrl(OperationOptions)

Retrieves an Azure Storage container URL. The container has feedback data for the notification hub. The caller can then use the Azure Storage Services SDK to retrieve the contents of the container.

function getFeedbackContainerUrl(options?: OperationOptions): Promise<string>

Parameters

options
OperationOptions

The options for getting the push notification feedback container URL.

Returns

Promise<string>

The URL of the Azure Storage Container containing the feedback data.

getInstallation(string, OperationOptions)

Gets an Azure Notification Hub installation by the installation ID.

function getInstallation(installationId: string, options?: OperationOptions): Promise<Installation>

Parameters

installationId

string

The ID of the installation to get.

options
OperationOptions

Configuration options for the get installation operation.

Returns

Promise<Installation>

The installation that matches the installation ID.

getNotificationHubJob(string, OperationOptions)

Gets a Notification Hub Job by the ID.

function getNotificationHubJob(jobId: string, options?: OperationOptions): Promise<NotificationHubJob>

Parameters

jobId

string

The Notification Hub Job ID.

options
OperationOptions

The operation options.

Returns

The Notification Hub Job with the matching ID.

getNotificationOutcomeDetails(string, OperationOptions)

Retrieves the results of a send operation. This can retrieve intermediate results if the send is being processed or final results if the Send* has completed. This API can only be called for Standard SKU and above.

function getNotificationOutcomeDetails(notificationId: string, options?: OperationOptions): Promise<NotificationDetails>

Parameters

notificationId

string

The notification ID returned from the send operation.

options
OperationOptions

The operation options.

Returns

The results of the send operation.

getRegistration(string, OperationOptions)

Gets a registration by the given registration ID.

function getRegistration(registrationId: string, options?: OperationOptions): Promise<RegistrationDescription>

Parameters

registrationId

string

The ID of the registration to get.

options
OperationOptions

The options for getting a registration by ID.

Returns

A RegistrationDescription that has the given registration ID.

listNotificationHubJobs(OperationOptions)

Gets all Notification Hub Jobs for this Notification Hub.

function listNotificationHubJobs(options?: OperationOptions): Promise<NotificationHubJob[]>

Parameters

options
OperationOptions

The operation options.

Returns

Promise<NotificationHubJob[]>

An array of all Notification Hub Jobs for this Notification Hub.

listRegistrations(RegistrationQueryLimitOptions)

Gets all registrations for the notification hub with the given query options.

function listRegistrations(options?: RegistrationQueryLimitOptions): PagedAsyncIterableIterator<RegistrationDescription, RegistrationDescription[], PageSettings>

Parameters

options
RegistrationQueryLimitOptions

The options for querying the registrations such as $top.

Returns

A paged async iterable containing all of the registrations for the notification hub.

listRegistrationsByChannel(RegistrationChannel, RegistrationQueryLimitOptions)

Gets all registrations for the notification hub with the given device information and options.

function listRegistrationsByChannel(channel: RegistrationChannel, options?: RegistrationQueryLimitOptions): PagedAsyncIterableIterator<RegistrationDescription, RegistrationDescription[], PageSettings>

Parameters

channel
RegistrationChannel

The registration channel information to query per PNS type.

options
RegistrationQueryLimitOptions

The options for querying the registrations such as $top.

Returns

A paged async iterable containing all of the registrations for the notification hub.

listRegistrationsByTag(string, RegistrationQueryLimitOptions)

Lists all registrations with the matching tag.

function listRegistrationsByTag(tag: string, options?: RegistrationQueryLimitOptions): PagedAsyncIterableIterator<RegistrationDescription, RegistrationDescription[], PageSettings>

Parameters

tag

string

The tag to query for matching registrations.

options
RegistrationQueryLimitOptions

The query options such as $top.

Returns

A paged async iterable containing the matching registrations for the notification hub.

scheduleBroadcastNotification(Date, Notification, OperationOptions)

Schedules a push notification to all devices at the specified time. NOTE: This is only available in Standard SKU Azure Notification Hubs.

function scheduleBroadcastNotification(scheduledTime: Date, notification: Notification, options?: OperationOptions): Promise<NotificationHubsMessageResponse>

Parameters

scheduledTime

Date

The Date to send the push notification.

notification
Notification

The notification to send to the matching devices.

options
OperationOptions

The operation options.

Returns

A NotificationHubResponse with the tracking ID, correlation ID and location.

scheduleNotification(Date, Notification, ScheduleNotificationOptions)

Schedules a push notification to devices that match the given tags or tag expression at the specified time. NOTE: This is only available in Standard SKU Azure Notification Hubs.

function scheduleNotification(scheduledTime: Date, notification: Notification, options: ScheduleNotificationOptions): Promise<NotificationHubsMessageResponse>

Parameters

scheduledTime

Date

The Date to send the push notification.

notification
Notification

The notification to send to the matching devices.

options
ScheduleNotificationOptions

Options which include tags used to target the device for push notifications in either an array or tag expression.

Returns

A NotificationHubResponse with the tracking ID, correlation ID and location.

sendBroadcastNotification(Notification, BroadcastSendNotificationOptions)

Sends push notifications to devices all devices.

function sendBroadcastNotification(notification: Notification, options?: BroadcastSendNotificationOptions): Promise<NotificationHubsMessageResponse>

Parameters

notification
Notification

The notification to send to all devices.

options
BroadcastSendNotificationOptions

Options for the notification including whether to enable test send.

Returns

A NotificationHubResponse with the tracking ID, correlation ID and location.

sendNotification(Notification, DirectSendNotificationOptions | SendNotificationOptions)

Sends push notifications to devices that match the given tags or tag expression.

function sendNotification(notification: Notification, options: DirectSendNotificationOptions | SendNotificationOptions): Promise<NotificationHubsMessageResponse>

Parameters

notification
Notification

The notification to send to the matching devices.

options

DirectSendNotificationOptions | SendNotificationOptions

Options for the notification including tags, device handles and whether to enable test send.

Returns

A NotificationHubResponse with the tracking ID, correlation ID and location.

submitNotificationHubJob(NotificationHubJob, OperationOptions)

Submits a Notification Hub Job. Note this is available to Standard SKU namespace and above.

function submitNotificationHubJob(job: NotificationHubJob, options?: OperationOptions): Promise<NotificationHubJob>

Parameters

job
NotificationHubJob

The notification hub job to submit.

options
OperationOptions

The operation options.

Returns

The notification hub job details including job ID and status.

updateInstallation(string, JsonPatch[], OperationOptions)

Updates an installation using the JSON-Patch standard in RFC6902.

function updateInstallation(installationId: string, patches: JsonPatch[], options?: OperationOptions): Promise<NotificationHubsResponse>

Parameters

installationId

string

The ID of the installation to update.

patches

JsonPatch[]

An array of patches following the JSON-Patch standard.

options
OperationOptions

Configuration options for the patch installation operation.

Returns

A NotificationHubResponse with the tracking ID, correlation ID and location.

updateRegistration(RegistrationDescription, OperationOptions)

Updates an existing registration.

function updateRegistration(registration: RegistrationDescription, options?: OperationOptions): Promise<RegistrationDescription>

Parameters

registration
RegistrationDescription

The registration to update.

options
OperationOptions

The operation options.

Returns

The updated registration description.