Share via


push object

 

Provides access to objects that are used for sending push notifications to apps from JavaScript backend Mobile Services. Mobile Services integrates with Azure Notification Hubs to support additional push notification functionality, such as templates, multiple platforms, and improved scale. For more information, see Get started with push notifications.

Members

Name

Returns

Description

apns

apns object

Returns an apns object that is used to send push notifications to an iOS app using the Apple Push Notification Service (APNS).

gcm

gcm object

Returns a gcm object that is used to send push notifications to an Android app using Google Cloud Messaging (GCM).

mpns

mpns object

Returns an mpns object that is used to send push notifications to a Windows Phone 8 or Window Phone Silverlight 8.1 app using the Microsoft Push Notification Service (MPNS).

wns

wns object

Returns a wns object that is used to send push notifications to a Windows Store app using Windows Notification Services (WNS).

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.

    Name

    Type

    Argument

    Description

    etag

    object

    <optional>

    The etag.

    callback

    object

    <optional>

    A JSON object that specifies the success and error callback functions.

  • createRegistrationId(callback)
    Creates a registration identifier.

    Parameters

    Name

    Type

    Argument

    Description

    callback

    object

    <optional>

    A JSON object that specifies the success and error callback functions.

  • deleteRegistration(registrationId, options, callback)
    Deletes a registration.

    Parameters

    Name

    Type

    Argument

    Description

    registrationId

    string

    The registration to delete.

    options

    object

    <optional>

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

    Name

    Type

    Argument

    Description

    etag

    object

    <optional>

    The etag.

    callback

    object

    <optional>

    A JSON object that specifies the success and error callback functions.

  • getRegistration(registrationId, options, callback)
    Retrieves an existing registration with the specified registrationId.

    Parameters

    Name

    Type

    Argument

    Description

    registrationId

    string

    The registration to retrieve.

    options

    object

    <optional>

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

    callback

    object

    <optional>

    A JSON object that specifies the success and error callback functions.

  • listRegistrations(options, callback)
    Returns all existing registrations.

    Parameters

    Name

    Type

    Argument

    Description

    options

    object

    <optional>

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

    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

    object

    <optional>

    A JSON object that specifies the success and error callback functions.

  • listRegistrationsByTag(tag, options, callback)
    Returns all existing registrations with the specified 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.

    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

    object

    <optional>

    A JSON object that specifies the success and error callback functions.

  • send(tags, payload, options, callback)
    Sends a template message.

    Parameters

    Name

    Type

    Argument

    Description

    tags

    string

    A single tag or tag expression. When null, the message is sent to all template registrations.

    payload

    object | string

    The template message payload.

    options

    object

    <optional>

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

    Name

    Type

    Argument

    Description

    headers

    object

    <optional>

    Additional headers.

    callback

    object

    <optional>

    A JSON object that specifies the success and error callback functions.

  • updateRegistration(registration, options, callback)
    Updates an existing registration.

    Parameters

    Name

    Type

    Argument

    Description

    registration

    object

    The registration to update.

    options

    object

    <optional>

    The registration to update. See the remarks section for the registration object definition.

    callback

    object

    <optional>

    A JSON object that specifies the success and error callback functions.

Remarks

The global push object is used to register for push notifications with Notification Hubs and send messages to template registrations. Use the platform-specific push objects to send messages to native registrations. While you can register for push notification from your Mobile Services backend, we recommend that you have the client register for notifications by calling registration methods on the client. For more information, see Add push notification to you Mobile Services app.

You can inject business logic into the client-initiated registration process. For more information, see Registration endpoint.

The callback object supplied to the callback parameter is defined as follows:

Callback object

Property

Type

Description

success

Function

Function that is called when the operation succeeds. The success response is passed to the function.

error

Function

Function that is called when the operation fails. The error response is passed to the function.

The following is an example of the callback object:

{ success: function(result){
      // Do something with the success response.
   }, error: function(error){
      // Do something with the error response.
   }
}

The registration object is defined as follows:

Registration object

Property

Type

Applies to

Description

registrationId

string

All

Registration id.

channelUri

string

WNS or MPNS-only

Current channel URI for the registration.

deviceToken

string

APNS-only

Current device token for the registration.

gcmRegistrationId

string

GCM-only

Current RegistrationId for the registration.

tags

string

All

Comma-separated list of tags (no spaces).

bodyTemplate

object

Template-only

Defines a template registration body.

wnsHeaders

object

WNS-only

Additional headers used with WNS.

mpnsHeaders

object

MPNS-only

Additional headers used with MPNS.

expiry

string

APNS-only

Expiration of the APNS registration.