Class: Installation

Installation Model connects a mobile application to the device, the user and other information for the server side to locate devices using application id/version, user id, device type, and subscriptions.

Class: Installation Static Methods

Installation.findByApp(deviceType, appId, [appVersion], cb)

Find installations by application id/version

Arguments
Name Type Description
deviceType String

The device type

appId String

The application id

[appVersion] String

The application version

cb Function

The callback function

Callback
Name Type Description
err Error or String

The error object

installations Array.<Installation>

The selected installations

Installation.findBySubscriptions(subscriptions, deviceType, cb)

Find installations by subscriptions

Arguments
Name Type Description
subscriptions String or Array.<String>

A list of subscriptions

deviceType String

The device type

cb Function

The callback function

Callback
Name Type Description
err Error or String

The error object

installations Array.<Installation>

The selected installations

Installation.findByUser(userId, deviceType, cb, cb)

Find installations by user id

Arguments
Name Type Description
userId String

The user id

deviceType String

The device type

cb Function

The callback function

cb Function

The callback function

Callback
Name Type Description
err Error or String

The error object

installations Array.<Installation>

The selected installations

Class: Notification

Notification

Notification Model

See the official documentation for more details on provider-specific properties.

Android - GCM

iOS - APN

Class Properties
Name Type Description
deviceType String

The device type such as ios.

deviceToken String

The device token as provided by GCM or APN.

alert Any

The notification's message (iOS only).

badge Number

The value indicated in the top right corner of the app icon. Set to -1 to increment the current value by one (iOS only).

sound String

The name of a sound file in the application bundle (iOS only).

category String

The category for the push notification action (iOS8+ only).

collapseKey String

An arbitrary string (such as "Updates Available") used to collapse a group of like messages when the device is offline, so only the last message gets sent to the client (Android only).

delayWhileIdle Boolean

Indicates that the message should not be sent immediately if the device is idle. The server will wait for the device to become active, and then only the last message for each collapse_key value will be sent (Android only).

created Date

The date that the notification is created.

modified Date

The date that the notifcation is modified.

scheduledTime Date

The time that the notification should be sent (not supported yet).

expirationTime Date

The time that the notification expires.

expirationInterval Number

The expiration interval in seconds. The interval starts at the time when the notification is sent to the push notification provider.

expirationInterval String

Status of the notification (not supported yet).

Class: PushManager(settings)

The PushManager class.

Arguments
Name Type Description
settings Object

The push settings.

settings
Name Type Description
ttlInSeconds Number

Time-to-live, in seconds.

checkPeriodInSeconds Number

Class: PushManager Instance Methods

pushManager.configureApplication(appId)

Lookup or set up push notification service for the given appId

Arguments
Name Type Description
appId String

The application id

Returns
Name Type Description
result

pushManager.configureProvider(deviceType, pushSettings)

Configure push notification for a given device type. Return null when no provider is registered for the device type.

Arguments
Name Type Description
deviceType String

The device type

pushSettings Object

The push settings

Returns
Name Type Description
result

pushManager.notify(installation, notification, cb)

Push a notification to the given installation. This is a low-level function used by the other higher-level APIs like notifyById and notifyByQuery.

Arguments
Name Type Description
installation Installation

Installation instance - the recipient.

notification Notification

The notification to send.

cb function(Error|undefined)

pushManager.notifyById(installationId, notification, cb)

Push a notification to the device with the given registration id.

Arguments
Name Type Description
installationId Object

Registration id created by call to Installation.create().

notification Notification

The notification to send.

cb function(Error|undefined)

pushManager.notifyByQuery(installationQuery, notification, cb)

Push a notification to all installations matching the given query.

Arguments
Name Type Description
installationQuery Object

Installation query, e.g. { appId: 'iCarsAppId', userId: 'jane.smith.id' }

notification Notification

The notification to send.

cb function(Error|undefined)

pushManager.notifyMany(application, type, device, notification, cb)

Push notification to installations for given devices tokens, device type and app.

Arguments
Name Type Description
application appId

id

type deviceType

of device (android, ios )

device deviceTokens

tokens of recipients.

notification Notification

The notification to send.

cb function(Error|undefined)