PlayerIO

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

Android Client Reference

Android  class documentationClass Notifications

Namespace: com.playerio
Language: Java

The Notifications service.

In order for the app to be able to receive push notifications, it must first enable Google Cloud Messaging in the Google Developer Console and obtain a GCM sender ID. See Getting Started with GCM for detailed instructions on how to do this. When your app launches, you must use Google Play Services API to obtain a registration id for the user device. See Implementing GCM Client for detailed instructions on how to obtain the registration ID. Once you have the registration ID, you need to send this ID to PlayerIO for push notifications to work using the following API: Once registered, game requests will automatically be received as push notifications. You can also send push notifications to a target user manually by creating a Notification object and sending it via the Send api: Note that you need to explicitly send the notification to all platforms that your game supports.

Methods

 
public void
deleteEndpoints (NotificationEndpoint[] endpoints, Callback<Void> callback)

Deletes the given endpoints

public NotificationEndpoint[]
getMyEndpoints ()

The list of notification endpoints registered for the current client.

public void
refresh (Callback<Void> callback)

Refreshes MyEndpoints public void refresh() throws PlayerIOError { NotificationsRefreshOutput output = channel.notificationsRefresh(version); refreshed(output.Version, output.Endpoints); } Refreshes MyEndpoints

public void
registerEndpoint (String endpointType, String identifier, Map<String,String> configuration, boolean enabled, Callback<Void> callback)

Register a device or endpoint with Player.IO.

public void
send (Notification[] notifications, Callback<Void> callback)

Send one or more notifications

public void
toggleEndpoints (NotificationEndpoint[] endpoints, boolean enable, Callback<Void> callback)

Enables or disabled the given endpoints.

Notifications.deleteEndpoints

public void
deleteEndpoints (NotificationEndpoint[] endpoints, Callback<Void> callback)

Deletes the given endpoints

Arguments

NotificationEndpoint[] endpoints
The endpoints to delete.
Callback<Void> callback
Callback that is invoked when operation completes

Notifications.getMyEndpoints

public NotificationEndpoint[]
getMyEndpoints ()

The list of notification endpoints registered for the current client.

Notifications.refresh

public void
refresh (Callback<Void> callback)

Refreshes MyEndpoints public void refresh() throws PlayerIOError { NotificationsRefreshOutput output = channel.notificationsRefresh(version); refreshed(output.Version, output.Endpoints); } Refreshes MyEndpoints

Arguments

Callback<Void> callback
Callback that will be called when the refresh is complete.

Notifications.registerEndpoint

public void
registerEndpoint (String endpointType, String identifier, Map<String,String> configuration, boolean enabled, Callback<Void> callback)

Register a device or endpoint with Player.IO.

Arguments

String endpointType
Endpoint type, such as, IOS, Android, email, etc.
String identifier
The identifier of the endpoint, such as the device token on iOS or an email address for email.
Map<String,String> configuration
Configuration relating to the endpoint. Can be null.
boolean enabled
Should the endpoint be enabled. <param callback Callback that will be called when the operation completes.
Callback<Void> callback

Notifications.send

public void
send (Notification[] notifications, Callback<Void> callback)

Send one or more notifications

Arguments

Notification[] notifications
The notifications to send
Callback<Void> callback
Callback that is invoked when operation completes

Notifications.toggleEndpoints

public void
toggleEndpoints (NotificationEndpoint[] endpoints, boolean enable, Callback<Void> callback)

Enables or disabled the given endpoints.

Arguments

NotificationEndpoint[] endpoints
The endpoints to enable or disable.
boolean enable
If true, all the given endpoints will be enabled. If false, they'll be disabled.
Callback<Void> callback
Callback that is invoked when operation completes