Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Enable Push

The Mobile Backend uses Google Cloud Messaging (GCM), to enable real-time push features Continuous Query and Pub/Sub Messaging . In the sample Guestbook app, messages sent from one client are automatically pushed to all other clients.

Enabling Google Cloud Messaging

Before using GCM, you must enable the API in Google's API Console :

  1. Open the Google API Console and make sure your Mobile Backend project is the active project by selecting it in the projects pulldown menu in the top left.
  2. Click Services .
  3. Locate Google Cloud Messaging for Android in the list of available services, and click the ON toggle.
  4. Accept the Terms of Services if you have not already.
  5. Click API Access in the top left of the API console.
  6. Scroll down to click Create new Server key... You don't need to supply any IP values in this form. (Using a server key allows you to whitelist IP addresses).
  7. Click Create .
  8. Locate the API key within the Key for server apps form and copy this key to the clipboard.
  9. Navigate to .appspot.com. This will bring you to your Mobile Backend Starter settings configuration page.
  10. Under Google Cloud Messaging and iOS Push Notification , toggle the radio button to "Enabled". Copy your API Key from the clipboard into the text box provided.
  11. Click Save .

Configuring the sample

  1. From the Google API Console , click Overview and locate the project number for your project:

    API Console

  2. Locate the PROJECT_NUMBER static in your Android project's Const.java file:

    /**
    * Set Project Number of your Google APIs Console Project.
    */
    public static final String PROJECT_NUMBER = "*** ENTER YOUR PROJECT NUMBER ***";
    
  3. Replace *** ENTER YOUR PROJECT NUMBER*** with the project number.

  4. Click Save .

Running the Sample

  1. Right-click your project in the Package Explorer pane, and select Run As > Android Application .
  2. Wait a few moments for the to be transferred onto your device.
  3. Start the client app.
  4. Repeat steps 1-3 with a second Android device.
  5. Enter some text into one of the devices and click Send . The message sent will be echoed with a timestamp:

    App Screenshot

  6. Check the second Android device or AVD. The same message should have been automatically pushed and is displayed there too.

Messages are currently not associated with a particular user. You'll do that next.

Next

Enable Authentication .

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.