Class: NotificationHubService

NotificationHubService

The NotificationHubService allows you to send push notifications to iOS, Android, and Windows Store devices.

For more information on Notification Hubs, as well as task focused information on using them from Node.js applications, see How to Use Service Bus Notification Hubs.

new NotificationHubService(hubName, endpointOrConnectionString, sharedAccessKeyName, sharedAccessKeyValue)

Creates a new NotificationHubService object.

Parameters:
Name Type Argument Description
hubName string

The notification hub name.

endpointOrConnectionString string <optional>

The service bus endpoint or connection string.

sharedAccessKeyName string <optional>

The notification hub shared access key name.

sharedAccessKeyValue string <optional>

The notification hub shared access key value.

Source:

Members

apns :ApnsService

Provides access to methods to send notifications to APNs (for iOS apps) and create/update registrations for iOS apps.

Type:
Source:

gcm :GcmService

Provides access to methods to send notifications to GCM (for Android apps) and create/update registrations for Android apps.

Type:
Source:

mpns :MpnsService

Provides access to methods to send notifications to MPNS (for Windows Phone apps) and create/update registrations for Windows Phone apps.

Type:
Source:

wns :WnsService

Provides access to methods to send notifications to WNS (for Windows Store apps) and create/update registrations for Windows Store apps.

Type:
Source:

Methods

createOrUpdateRegistration(registration, options, callback)

Creates or updates a registration.

Parameters:
Name Type Argument Description
registration string

The registration to update.

options object <optional>

The request options or callback function. Additional properties will be passed as headers.

Properties
Name Type Argument Description
etag object <optional>

The etag.

callback function

error will contain information if an error occurs; otherwise, response will contain information related to this operation.

Source:

createRegistrationId(callback)

Creates a registration identifier.

Parameters:
Name Type Description
callback function

error will contain information if an error occurs; otherwise, response will contain information related to this operation.

Source:

deleteRegistration(registrationId, options, callback)

Deletes a registration.

Parameters:
Name Type Argument Description
registrationId string

The registration identifier.

options object <optional>

The request options or callback function. Additional properties will be passed as headers.

Properties
Name Type Argument Description
etag object <optional>

The etag.

callback function

error will contain information if an error occurs; otherwise, response will contain information related to this operation.

Source:

getRegistration(registrationId, options, callback)

Retrieves a registration.

Parameters:
Name Type Argument Description
registrationId string

The registration identifier.

options object <optional>

The request options or callback function. Additional properties will be passed as headers.

callback function

error will contain information if an error occurs; otherwise, response will contain information related to this operation.

Source:

listRegistrations(options, callback)

List registrations.

Parameters:
Name Type Argument Description
options object <optional>

The request options or callback function. Additional properties will be passed as headers.

Properties
Name Type Argument Description
top object <optional>

Specifies the maximum number of registration to obtain from the call.

skip object <optional>

Specifies the number of registrations to skip in the call.

callback function

error will contain information if an error occurs; otherwise, response will contain information related to this operation.

Source:

listRegistrationsByTag(tag, options, callback)

Retrieves a registration by tag.

Parameters:
Name Type Argument Description
tag string

The registration tag.

options object <optional>

The request options or callback function. Additional properties will be passed as headers.

Properties
Name Type Argument Description
top object <optional>

Specifies the maximum number of registration to obtain from the call.

skip object <optional>

Specifies the number of registrations to skip in the call.

callback function

error will contain information if an error occurs; otherwise, response will contain information related to this operation.

Source:

send(tags, payload, options, callback)

Sends a template message.

Parameters:
Name Type Argument Description
tags string

A single tag or tag expression. If null it will broadcast to all registrations in this hub

payload object | string

The message's payload.

options object <optional>

The request options or callback function.

Properties
Name Type Argument Description
headers string <optional>

Additional headers.

callback function

error will contain information if an error occurs; otherwise, response will contain information related to this operation.

Source:
Example
var azure = require('azure');
var notificationHubService = azure.createNotificationHubService('hubName', '{connection string}');
notificationHubService.send( null, { message: 'This is my toast message for iOS!' }, function (error) {
  if (!error) {
    // message sent successfully
  }
});

updateRegistration(registration, options, callback)

Updates a registration.

Parameters:
Name Type Argument Description
registration object

The registration to update.

Properties
Name Type Description
RegistrationId object

Registration id to update

_.ContentRootElement object

Type of the registration. Types allowed: WindowsRegistrationDescription, WindowsTemplateRegistrationDescription, AppleRegistrationDescription, AppleTemplateRegistrationDescription, GcmRegistrationDescription, GcmTemplateRegistrationDescription, MpnsRegistrationDescription, MpnsTemplateRegistrationDescription.

ChannelUri object

Only if Windows or Mpns registration

DeviceToken object

Only if Apple registration

GcmRegistrationId object

Only if Gcm registration

Tags object

Comma-separated list of tags (no spaces)

BodyTemplate object

Only if template registration

WnsHeaders object

Only if Windows template registration

MpnsHeaders object

Only if Mpns template registration

Expiry object

Only if Apple template registration

options object <optional>

The request options or callback function. Additional properties will be passed as headers.

Properties
Name Type Argument Description
etag object <optional>

The etag.

callback function

error will contain information if an error occurs; otherwise, response will contain information related to this operation.

Source: