PlayerIO

The fastest way to build online games without breaking a sweat.

HTML5 (Javascript) Client Reference

javascript (html5) notifications class informationClass notifications

Language: Javascript (HTML5)

The Notifications service. This class is used for registering mobile endpoints and sending mobile push notifications to other users.

Example

Refresh and list the user's registered endpoints:

Example

Registering a notification endpoint for the current client:

Example

Sending a notification:

Properties

 
myEndpoints :notificationEndpoint[]

The list of registered endpoints for the current user. You must call refresh() first to initialize this list.

Methods

 
deleteEndpoints (endpoints, successCallback, errorCallback):

Deletes the given endpoints

refresh (successCallback, errorCallback):

Refresh the notification endpoints of the current user.

registerEndpoint (endpointType, identifier, configuration, enabled, successCallback, errorCallback):

Register a device or endpoint with Player.IO

send (notifications, successCallback, errorCallback):

Send one or more notifications

toggleEndpoints (endpoints, enabled, successCallback, errorCallback):

Enables or disabled the given endpoints

notifications.myEndpoints

myEndpoints :notificationEndpoint[]

The list of registered endpoints for the current user. You must call refresh() first to initialize this list.

notifications.deleteEndpoints

deleteEndpoints (endpoints, successCallback, errorCallback):

Deletes the given endpoints

Arguments

endpoints:notificationEndpoint[]
The endpoints to delete
successCallback:function()
Callback function that will be called when the operation has been completed.
errorCallback:function(PlayerIOError)
Callback function that will be called if an error occurs.

notifications.refresh

refresh (successCallback, errorCallback):

Refresh the notification endpoints of the current user.

Arguments

successCallback:function()
Callback function that will be called when the refresh is complete
errorCallback:function(PlayerIOError)
Callback function that will be called if an error occurs

notifications.registerEndpoint

registerEndpoint (endpointType, identifier, configuration, enabled, successCallback, errorCallback):

Register a device or endpoint with Player.IO

Arguments

endpointType:string
Endpoint type, such as, IOS, Android, email, etc.
identifier:string
The identifier of the endpoint, such as the device token on iOS or an email address for email.
configuration:object
Configuration relating to the endpoint. Can be null.
enabled:bool
Should the endpoint be enabled
successCallback:function()
Callback function that will be called when the operation has been completed.
errorCallback:function(PlayerIOError)
Callback function that will be called if an error occurs.

notifications.send

send (notifications, successCallback, errorCallback):

Send one or more notifications

Arguments

notifications:object[]
The notifications to send
successCallback:function()
Callback function that will be called when the operation has been completed.
errorCallback:function(PlayerIOError)
Callback function that will be called if an error occurs.

notifications.toggleEndpoints

toggleEndpoints (endpoints, enabled, successCallback, errorCallback):

Enables or disabled the given endpoints

Arguments

endpoints:notificationEndpoint[]
The endpoints to enable or disable.
enabled:bool
If true, all the given endpoints will be enabled. If false, they'll be disabled.
successCallback:function()
Callback function that will be called when the operation has been completed.
errorCallback:function(PlayerIOError)
Callback function that will be called if an error occurs.