blob: f6b7ebe8244b1787af065ae8590cdb11942fd771 [file] [log] [blame]
page.title=Getting Started
page.tags="cloud","push","messaging"
@jd:body
<div id="qv-wrapper">
<div id="qv">
<h2>In this document</h2>
<ol class="toc">
<li><a href="#create-proj">Creating a Google API Project</a></li>
<li><a href="#gcm-service">Enabling the GCM Service</a></li>
<li><a href="#access-key">Obtaining an API Key</a></li>
<li><a href="#next">Next Steps</a></li>
</ol>
<h2>See Also</h2>
<ol class="toc">
<li><a href="https://code.google.com/apis/console">Google APIs Console page</a></li>
<li><a href="https://services.google.com/fb/forms/gcm/" class="external-link" target="_android">CCS and User Notifications Signup Form</a></li>
</ol>
</div>
</div>
<p>This document tells you how to get started setting up a GCM
implementation.
Before you begin, make sure to <a href="/google/play-services/setup.html">set up
the Google Play Services SDK</a>. You need this SDK to use the
<a href="{@docRoot}reference/com/google/android/gms/gcm/GoogleCloudMessaging.html">
{@code GoogleCloudMessaging}</a> methods.</p>
<h2 id="create-proj">Creating a Google API project</h2>
<p>To create a Google API project:</p>
<ol>
<li>Open the <a href="https://code.google.com/apis/console">Google APIs Console page</a>.
</li>
<li>If you haven't created an API project yet, this page will prompt you to do so:
<p><img src="{@docRoot}images/gcm/gcm-create-api-proj.png" class="screenshot" /></p>
<p class="note"><strong>Note:</strong> If you already have existing projects,
the first page you see will be the <strong>Dashboard</strong> page. From there
you can create a new project by opening the project drop-down menu (upper left corner)
and choosing <strong>Other projects > Create</strong>.</p></li>
<li> Click <strong>Create project</strong>.
Your browser URL will change to something like:</li>
<pre> https://code.google.com/apis/console/#project:<strong>4815162342</strong></pre>
<li> Take note of the value after <code>#project:</code> (4815162342 in this
example). This is your project number, and it will be used later on as the GCM sender ID.</li>
</ol>
<h2 id="gcm-service">Enabling the GCM Service</h2>
<p>To enable the GCM service:</p>
<ol>
<li> In the main Google APIs Console page, select <strong>Services</strong>.</li>
<li>Turn the <strong>Google Cloud Messaging</strong> toggle to ON.</li>
<li>In the Terms of Service page, accept the terms.
</li>
</ol>
<h2 id="access-key">Obtaining an API Key</h2>
<p>To obtain an API key:</p>
<ol>
<li> In the main Google APIs Console page, select <strong>API Access</strong>.
You will see a screen that resembles the following:</li>
<img src="{@docRoot}images/gcm/gcm-api-access.png" style="width:400px;padding:4px;">
<li>Click <strong>Create new Server key</strong>. Either a server key or a
browser key should work. The advantage to using a server key is that it allows
you to whitelist IP addresses. The following screen appears:</li>
<img src="{@docRoot}images/gcm/gcm-config-server-key.png" style="width:400px;padding:4px;">
<li>Click <strong>Create</strong>:</li>
<img src="{@docRoot}images/gcm/gcm-api-key.png" style="width:400px;padding:4px;">
</ol>
<p> Take note of the <strong>API key</strong> value (<code>YourKeyWillBeShownHere</code>)
in this example, as it will be used later on.</p>
<p class="note"><strong>Note:</strong> If you need to rotate the key, click
<strong>Generate new key</strong>. A new key will be created while the old one
will still be active for up to 24 hours. If you want to get rid of the old key
immediately (for example, if you feel it was compromised), click <strong>Delete key</strong>.</p>
<h2 id="next">Next Steps</h2>
<p>Once you've finished the tasks listed above, you're ready to start
implementing GCM. Here is an overview of the basic steps:</p>
<ol>
<li>Decide which Google-provided GCM connection server you want to use&mdash;
<a href="http.html">HTTP</a> or <a href="ccs.html">XMPP</a> (CCS). GCM connection servers
take messages from a 3rd-party application
server (written by you) and send them to a GCM-enabled Android application (the
"client app," also written by you) running on a device. </li>
<li>Implement an application server (the "3rd-party application server") to interact
with your chosen GCM connection server. The app server sends data to a
GCM-enabled Android client application via the GCM connection server. For more
information about implementing the server side, see <a href="server.html">
Implementing GCM Server</a>.</li>
<li>Write your client app. This is the GCM-enabled Android application that runs
on a device. See <a href="client.html">Implementing GCM Client</a> for more information.</li>
</ol>