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
100
101
102
103
|
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>
<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://cloud.google.com/console">Google Cloud 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 > Registered apps</strong>.</li>
<li>Click <strong>Register app</strong>. </li>
<li>In the <strong>Name</strong> field, type your app's name.</li>
<li>Click <strong>Android > Accessing APIs directly from Android</strong>.</li>
<li>Under <strong>Android identification</strong>, type the package name for your app.</li>
<li>Enter an SHA1 fingerprint. To get this value, follow the instructions in the
<a href="http://developers.google.com/console/help/new/#installedapplications">console
help</a>.</li>
<li>Click <strong>Register</strong>.</li>
<li>In the new page, open the <strong>Android Key</strong> section and 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
the "recycle key" icon. A new key will be created. If you think the key has been compromised
and you want to delete it immediately, you can accomplish this by deleting the app from
the console. Then create a new entry for the app with the same SHA1 and package name.</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>
|