Push Notifications enable mobile application providers to push data to the client, as opposed to requiring clients to poll for updates.
PlayerIO allows notifications to be sent for every Game Request.
The notifications system communicates directly with two notification providers, APNS for iOS and the GCM platform on Android, and provides an abstraction that enables games to push notifications to all Notification Endpoints of a target user.
A Notification Endpoint is any place where the target user can receive a push notification. For example, a user that has an Android phone as well as an iPad, may have two endpoints associated with him or her. If both endpoints are registered to the game, then both of these endpoints will be targetted when a notification is sent to that user.
Note: Delivery of a Push Notification is not guaranteed!
Push Notifications are a convenient way to capture the attention of a user, but should not be used to evoke any state-change in a game as Apple's APNS (Apple Push Notifications System) or Google's GCM (Google Cloud Messaging) may decide to drop them for various potential reasons. It is a good idea, however, to embed information that will help your app to open a relevant scene. For example, in a Chess game a user may be notified of a request for playing their turn. If this notification is acted apon, the game can open the exact chess board for which the notification was sent.
Adding Push Notifications support to your App
In order for push notifications to work, you need to register with the notifications service of each target platform your game will support.
For iOS, this means that you must turn them on explicitly for your app via the developer portal and then obtain a certificate that you must upload to the Games Control Panel. For more details on this, see iOS
For Android, you must obtain a SENDER_ID, which is the project id of your game on Google Play. For more details on this, see Google
Registering a Notification Endpoint
In order to register an endpoint the game must use the Client Libraries to send a unique identifier of the endpoint that will be understood by the notifications provider.
On iOS, this means the game must pass to PlayerIO the device token that Apple will provide via the didRegisterForRemoteNotificationsWithDeviceToken event.
On Android this identifier will be the registrationId returned by the GoogleCloudMessaging.register method.
Sending a Notification via the Notifications Control Panel
You can send a notification to a user directly from the Control Panel. This can be useful for testing that notifications are working.
- Go to the Notifications Control Panel.
- Select the 'Users' tab.
- Enter the ConnectUserId of the user you wish to send the notification to.
- Click 'Find User'.
- You'll get back a list of all notification endpoints registered for that user. Click 'Send Test Notification' for the endpoint you wish to send the notification to.