Adding Push Notifications in Your iOS Game

You can enable push notifications in your iOS game so that users are alerted when they receive invitations to a multiplayer game or when updates occur in a turn-based match.

To enable push notifications for your iOS game, follow these steps:

  1. Create and download an Apple Push Notification service (APNS) certificate. To learn how to create an APNS certificate, you can refer to Apple Developer Provisioning and Development documentation, under 'Creating the SSL Certificate and Keys'. Note that Google Play games services does not accept a certificate with a blank password.
  2. Create a provisioning profile that contains push notification entitlements. To learn how to create a provisioning profile, you can refer to the Apple Developer Provisioning and Development documentation, under 'Creating and Installing the Provisioning Profile'. Make sure to drag the provisioning profile to your test device in the organizer.
  3. Upload the .p12 file that you created to the Google Play Console. The .p12 file must be in the PKCS #12 format, and must contain only a single certificate.

    1. Select the iOS linked app for your game.
    2. In the Development Certificate section, click on Add certificate and follow the prompts. The bundle identifier string is case-sensitive. Make sure that the bundle identifier you specify for your certificate exactly matches the bundle identifier you have created for your sample application.

    The Apple Push Notifications certificate setup screen in the Google
  Play Developer Console

  4. Next, register your app to receive push notifications after the user successfully signs-in. Add the following code in your finishedWithAuth:error handler, at the point where the user has successfully signed in to Google Play games services. This brings up the standard iOS push notifications dialog. If your game already has registered for push notifications by implementing this code elsewhere, then you don't need to add this line again.

    [[UIApplication sharedApplication] registerForRemoteNotifications:
    (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)];
    
  5. In your appDelegate, add the following code to the callback for retrieving the push device token passed back from APNS. This device token is used for outbound push notifications, and your app must register it with the Google Play games services push service. Make sure to always register your device token through GPGManager to enable push notifications from Google Play games services. Even if the user has not signed in; the GPGmanager object will cache this token and save it until the user signs in.

    - (void)application:(UIApplication *)application
            didRegisterForRemoteNotificationsWithDeviceToken
            :(NSData *)deviceToken {
        NSLog(@"Got deviceToken from APNS! %@", deviceToken);
        [[GPGManager sharedInstance] registerDeviceToken:deviceToken
                forEnvironment:GPGPushNotificationEnvironmentSandbox];
    }
    

Now when users start your game and successfully sign-in, they should see a dialog requesting permission for your game to send push notifications to the device.

Send feedback about...

Play Games Services for iOS
Play Games Services for iOS