1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
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://cloud.google.com/console">Google Cloud Console</a></li>
<li><a href="https://developers.google.com/console/help/new/">Google Cloud Console Help</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://cloud.google.com/console">Google Developers Console</a>.
</li>
<li>If you haven't created an API project yet, click <strong>Create Project</strong>.</li>
<li>Supply a project name and click <strong>Create</strong>.
<p>Once the project has been created, a page appears that displays your project ID and
project number. For example, <strong>Project Number: 670330094152</strong>.</p></li>
<li>Copy down your project number. You will use it later on as the
<a href="{@docRoot}google/gcm/gcm.html#senderid">GCM sender ID</a>.</li>
</ol>
<h2 id="gcm-service">Enabling the GCM Service</h2>
<p>To enable the GCM service:</p>
<ol>
<li>In the sidebar on the left, select <strong>APIs & auth</strong>. </li>
<li>In the displayed list of APIs, turn the <strong>Google Cloud Messaging for Android
</strong> toggle to ON.</li>
</ol>
<h2 id="access-key">Obtaining an API Key</h2>
<p>To obtain an API key:</p>
<ol>
<li>In the sidebar on the left, select <strong>APIs & auth > Credentials</strong>.</li>
<li>Under <strong>Public API access</strong>, click <strong>Create new key</strong>.</li>
<li>In the <strong>Create a new key</strong> dialog, click <strong>Server key</strong>.</li>
<li>In the resulting configuration dialog, supply your server's IP address. For testing
purposes, you can use {@code 0.0.0.0/0}.</p></li>
<li>Click <strong>Create</strong>.</li>
<li>In the refreshed page, copy the
<a href="{@docRoot}google/gcm/gcm.html#apikey">API key</a>.
You will need the API key later on to perform authentication in your application server.</li>
<p class="note"><strong>Note:</strong> If you need to rotate the key, click
<strong>Regenerate key</strong>. A new key will be created. If you think the key has been
compromised and you want to delete it immediately, click <strong>Delete</strong>.</p>
</ol>
<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—
<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>
|