- The player’s device OS (Android, iOS, etc.)
- The vendor-specific channel (Google, Apple, etc.)
- Cross-platform message routing (PlayFab via Amazon Simple Notification Service (SNS)).
If any of these systems are unlinked, clients will stop getting notifications. It is fairly simple to accidentally change one of the three systems, and wind up breaking the link. Furthermore, it is difficult to know at any individual point in the flow if all of the systems are configured properly.
The PlayFab push routing system
Every PlayFab title can enable one Google (GCM), and one Apple Push (APNS, APNS_SANDBOX) notification channel at a given time. These can be configured in one of two ways:- Using the UI in Game Manager under Settings -> Push Notifications.
- Using the PlayFab Admin API - SetupPushNotification.
Push messages in-game
Push messages will vary based on the development engine/platform. However, the easiest way to receive push notifications is using a Unity project with our SDK and the Firebase Cloud Messaging (FCM) plugin for Android, or just Unity for iOS.- Receiving push on Android - This requires a plugin. The best supported plugin is the native FCM plugin.
- Receiving push on iOS - This does not require a plugin for basic push messages.
Testing the setup
After configuring your title and client, you can test your configuration using the PlayFab server API - SendPushNotification. This API allows you to send as many push notifications as needed at no extra cost. You can use the PlayFab CloudScript service as a quick and secure server API environment. From there, push notifications can be sent as needed. To use this method to test your configuration, upload or append the code in the following example to your title’s CloudScript.Example
Consider the following scenario:- Players in your title may access a leaderboard based on rank statistics.
- Each player may pay 1 CH currency, and challenge another player who is up to 5 positions away from the current player.
ChallengePlayer.
ChallengePlayer CloudScript code will handle the request, validate the leaderboard state, and send the challenge push notification to the target.
Push notification usage
Having the ability to use push notifications is an awesome power. When abused, however, it can cause users to opt out of future notifications - or even leave a game entirely. If used judiciously, though, push notifications can be one of your best tools for building and maintaining your game community. Push notifications are a fire and forget message protocol which does not guarantee delivery.Remember that there is no guarantee that your players will receive, open, or engage with your message. Given that caveat, it is a good practice to use messages as bonus functionality, rather than as a critical part of your gameplay loop.
- The App is updated or reinstalled.
- The user makes changes to the settings from their phone’s settings menu.
Resources
The following resources provide additional information about the topics in this quickstart:- Firebase Unity SDK: An all-in-one FCM solution for Unity. This SDK, among all other features, allows you to receive and process push notifications sent via FCM.
- Push It Real Good: How to Get Players to Say Yes to Push Notifications: This blog post details additional strategies and techniques for using push notifications.
- Push Notifications: This blog post describes the most recent upgrade in Push functionality, and switching to FCM as the primary plugin for Android.
- Postman Quickstart: This quickstart shows you how to test our APIs using Postman.
