+

Search Tips | Advanced Search

For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.


Configure the Application Center server for connection to Google Cloud Messaging

Enable Google Cloud Messaging (GCM) for our application.

To enable Google Cloud Messaging (GCM) for an application, we must attach the GCM services to a developer Google account with the Google API enabled. See Getting Started with GCM for details.

Important: The Application Center client without Google Cloud Messaging: The Application Center relies on the availability of the Google Cloud Messaging (GCM) API. This API might not be available on devices in some territories such as China. To support those territories, we can build a version of the Application Center client that does not depend on the GCM API. The push notification feature does not work on that version of the Application Center client. See Build a version of the mobile client that does not depend on the GCM API for details.


Procedure

  1. If you do not have the appropriate Google account, go to Create a Google account and create one for the Application Center client.
  2. Register this account by using the Google API in the Google API console. Registration creates a new default project that we can rename. The name you give to this GCM project is not related to our Android application package name. When the project is created, a GCM project ID is appended to the end of the project URL. You should record this trailing number as your project ID for future reference.
  3. Enable the GCM service for our project; in the Google API console, click the Services tab on the left and enable the "Google Cloud Messaging for Android" service in the list of services.
  4. Make sure that a Simple API Access Server key is available for our application communications.

    1. Click the API Access vertical tab on the left of the console.
    2. Create a Simple API Access Server key or, if a default key is already created, note the details of the default key. Two other kinds of key exist that are not of interest at this time.
    3. Save the Simple API Access Server key for future use in your application communications through GCM. The key is about 40 characters long and is referred to as the Google API key that you will need later on the server side.
  5. Enter the GCM project ID as a string resource property in the JavaScript project of the Application Center Android client; in the IBMAppCenter/apps/AppCenter/common/js/appcenter/config.json template file, modify this line with your own value:

      gcmProjectId:""// Google API project (project name = com.ibm.appcenter) ID needed for Android push.
      // example : 123456789012

  6. Register the Google API key as a JNDI property for the Application Center server. The key name is : ibm.appcenter.gcm.signature.googleapikey. For example, we can configure this key for an Apache Tomcat server as a JNDI property in the server.xml file:

      <Context docBase="AppCenterServices" path="/applicationcenter" reloadable="true" source="org.eclipse.jst.jee.server:AppCenterServices">
      <Environment name="ibm.appcenter.gcm.signature.googleapikey" override="false" type="java.lang.String" 
      value="AIxaScCHg0VSGdgfOZKtzDJ44-oi0muUasMZvAs"/>
      </Context>

    The JNDI property must be defined in accordance with your application server requirements.

    See JNDI properties for Application Center for a complete list of properties that we can set.

    Important:

    • If we use GCM with earlier versions of Android, you might need to pair your device with an existing Google account for GCM to work effectively. See GCM service: "It uses an existing connection for Google services. For pre-3.0 devices, this requires users to set up their Google account on their mobile devices. A Google account is not a requirement on devices running Android 4.0.4 or higher."
    • You must also ensure that your firewall accepts outgoing connections to android.googleapis.com on port 443 for push notifications to work.

Parent topic: Push notifications of application updates