Skip to content

Commit 2611253

Browse files
authored
Require a SENDER_ID now. (#615)
1 parent 0579589 commit 2611253

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Parse/src/main/java/com/parse/GcmRegistrar.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
private static final String REGISTRATION_ID_EXTRA = "registration_id";
3939
private static final String ERROR_EXTRA = "error";
4040

41-
// Client-side key for [email protected]. See parse/config/gcm.yml for server-side key.
42-
private static final String PARSE_SENDER_ID = "1076345567071";
4341
private static final String SENDER_ID_EXTRA = "com.parse.push.gcm_sender_id";
4442

4543
public static final String REGISTER_ACTION = "com.google.android.c2dm.intent.REGISTER";
@@ -134,24 +132,33 @@ private Task<Void> sendRegistrationRequestAsync() {
134132
// a 32-bit integer. For `android:value="567327206255"`, this returns a truncated integer
135133
// because 567327206255 is larger than the largest 32-bit integer.
136134
Bundle metaData = ManifestInfo.getApplicationMetadata(context);
137-
String senderIDs = PARSE_SENDER_ID;
135+
String senderID = null;
136+
138137
if (metaData != null) {
139138
Object senderIDExtra = metaData.get(SENDER_ID_EXTRA);
140139

141140
if (senderIDExtra != null) {
142-
String senderID = actualSenderIDFromExtra(senderIDExtra);
141+
senderID = actualSenderIDFromExtra(senderIDExtra);
143142

144-
if (senderID != null) {
145-
senderIDs += ("," + senderID);
146-
} else {
143+
if (senderID == null) {
147144
PLog.e(TAG, "Found " + SENDER_ID_EXTRA + " <meta-data> element with value \"" +
148145
senderIDExtra.toString() + "\", but the value is missing the expected \"id:\" " +
149146
"prefix.");
147+
return null;
150148
}
151149
}
152150
}
153151

154-
request = Request.createAndSend(context, senderIDs);
152+
if (senderID == null) {
153+
PLog.e(TAG, "You must provide " + SENDER_ID_EXTRA + " in your AndroidManifest.xml\n" +
154+
"Make sure to prefix with the value with id:\n\n" +
155+
"<meta-data\n" +
156+
" android:name=\"com.parse.push.gcm_sender_id\"\n" +
157+
" android:value=\"id:<YOUR_GCM_SENDER_ID>\" />");
158+
return null;
159+
}
160+
161+
request = Request.createAndSend(context, senderID);
155162
return request.getTask().continueWith(new Continuation<String, Void>() {
156163
@Override
157164
public Void then(Task<String> task) {

0 commit comments

Comments
 (0)