*

Push Notification Setup – Google

In this tutorial we walk you through the steps to configure Google Cloud Messaging (GCM) with brainCloud.

Prerequisites

  • Must have a Google developer account
  • Must have created an app on the Google developer console site
  • Must have entered appropriate Google information in “Core App Info | Application IDs” seciont of the brainCloud portal

 

Create GCM API key for brainCloud

Enable the GCM API

  • Navigate your browser to the Google developer console site
  • Select your app
    brainCloud
  • Click the “APIs & auth | APIs” link on the left hand nav bar
    brainCloud
  • Select “Cloud Messaging for Android
  • Enable the API

Create Public Access Key

  • Navigate to the “API | Credentials” page
  • Create New Key under “Public API access”
  • Select “Server Key”
    brainCloud
  • Hit the Create button
    brainCloud
  • You should now have a server API key:
    brainCloud
  • Navigate to the brainCloud portal and enter this key in the Notifications | Settings for Google Play.
    brainCloud

 

Enable GCM For Your App

In addition to the above steps, you will need to do the following in order for GCM to work in your app.

Link your Google Console game to Google Play

Apparently these two systems can’t talk to each other. Do the following to establish a link between the two systems.

  • Navigate to the Google Play Developer site (play.google.com/apps/publish)
  • Click Game Services in left hand navigation bar
    brainCloud
  • Click Add New Game button on top right
  • Fill in the appropriate info in the Add Game dialog making sure to select “I already use Google APIs in my game” and using the appropriate game (Hello World is probably *not* the correct game).
    brainCloud

 

Registering GCM Notification Token With brainCloud

After Authenticating a user with brainCloud, you will want to Register their GCM notification token with brainCloud. Specifically you’ll want to call the BrainCloudPushNotifications.RegisterDeviceToken() and pass in the registration id. In order to get this registration id, follow these steps.

Note that this example assume you are working in Java on an Android device. For developers using Unity (or a Unity plugin such as Prime31), follow the appropriate instructions available elsewhere.

  • Find your “Sender Id” – the number which appears under your app’s name in the Game Services section of the Google Play developer site.
    brainCloud
  • This Sender Id is what you will need to pass to the GCM Java API to get a registration id. The code below shows how to retrieve the registration id:
    brainCloud
  • Once you have the registration id you will want to call BrainCloudPushNotifications.RegisterDeviceToken()

Other Google Configuration Stuff

A few other tasks remain to link credentials together etc.

Create OAuth Key

  • In the Google Developer Console navigate to the “Apis & auth | Credentials” section
  • Under the OAuth section click “Create new Client ID”
  • Fill in the appropriate info
    brainCloud
  •  Your Client ID should now available
    brainCloud

Link Client ID to Google Play

  • Navigate to the Google Play Developer Console
  • Select Game Services for your app from left hand navigation bar
  • Click “Linked Apps”
    brainCloud
  • Click “Android” button
  • Enter the appropriate information for your app
    brainCloud
  • And finally, verify that your Client ID is linked in correctly
    brainCloud
  • Take a breath of fresh air, you are finally *done*!