Skip to content

Commit acd2db1

Browse files
committed
Clean up Push warnings
1 parent a3000f2 commit acd2db1

File tree

3 files changed

+31
-45
lines changed

3 files changed

+31
-45
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ public Task<Void> registerAsync() {
9696
final ParseInstallation installation = ParseInstallation.getCurrentInstallation();
9797
// Check whether we need to send registration request, if installation does not
9898
// have device token or local device token is stale, we need to send request.
99-
Task<Boolean> checkTask = installation.getDeviceToken() == null ? Task.forResult(true) :
100-
isLocalDeviceTokenStaleAsync();
99+
Task<Boolean> checkTask = installation.getDeviceToken() == null
100+
? Task.forResult(true)
101+
: isLocalDeviceTokenStaleAsync();
101102
return checkTask.onSuccessTask(new Continuation<Boolean, Task<Void>>() {
102103
@Override
103104
public Task<Void> then(Task<Boolean> task) throws Exception {

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

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -220,47 +220,39 @@ public static PushType getPushType() {
220220
} else {
221221
pushType = PushType.NONE;
222222

223-
// Emit warnings if the client doesn't get push due to misconfiguration of the manifest.
224-
if (hasAnyGcmSpecificDeclaration && !hasRequiredGcmDeclarations) {
223+
if (hasAnyGcmSpecificDeclaration) {
224+
if (!hasPushBroadcastReceiver) {
225+
/* Throw an error if someone migrated from an old SDK and hasn't yet started using
226+
* ParsePushBroadcastReceiver. */
227+
PLog.e(TAG, "Push is currently disabled. This is probably because you migrated from " +
228+
"an older version of Parse. This version of Parse requires your app to have a " +
229+
"BroadcastReceiver that handles " + ParsePushBroadcastReceiver.ACTION_PUSH_RECEIVE +
230+
", " + ParsePushBroadcastReceiver.ACTION_PUSH_OPEN + ", and " +
231+
ParsePushBroadcastReceiver.ACTION_PUSH_DELETE + ". You can do this by adding " +
232+
"these lines to your AndroidManifest.xml:\n\n" +
233+
" <receiver android:name=\"com.parse.ParsePushBroadcastReceiver\"\n" +
234+
" android:exported=false>\n" +
235+
" <intent-filter>\n" +
236+
" <action android:name=\"com.parse.push.intent.RECEIVE\" />\n" +
237+
" <action android:name=\"com.parse.push.intent.OPEN\" />\n" +
238+
" <action android:name=\"com.parse.push.intent.DELETE\" />\n" +
239+
" </intent-filter>\n" +
240+
" </receiver>");
241+
}
242+
if (!isGooglePlayServicesAvailable) {
243+
PLog.e(TAG, "Cannot use GCM for push on this device because Google Play " +
244+
"Services is not available. Install Google Play Services from the Play Store.");
245+
}
246+
// Emit warnings if the client doesn't get push due to misconfiguration of the manifest.
247+
if (!hasRequiredGcmDeclarations) {
225248
/*
226249
* If we detect that the app has some GCM-specific declarations, but not all required
227250
* declarations for GCM, then most likely the client means to use GCM but misconfigured
228251
* their manifest. Log an error in this case.
229252
*/
230-
PLog.e(TAG, "Cannot use GCM for push because the app manifest is missing some " +
231-
"required declarations. Please " + getGcmManifestMessage());
232-
} else if (!hasPushBroadcastReceiver &&
233-
(hasRequiredGcmDeclarations || hasRequiredPpnsDeclarations)) {
234-
/* Throw an error if someone migrated from an old SDK and hasn't yet started using
235-
* ParsePushBroadcastReceiver. */
236-
PLog.e(TAG, "Push is currently disabled. This is probably because you migrated from " +
237-
"an older version of Parse. This version of Parse requires your app to have a " +
238-
"BroadcastReceiver that handles " + ParsePushBroadcastReceiver.ACTION_PUSH_RECEIVE +
239-
", " + ParsePushBroadcastReceiver.ACTION_PUSH_OPEN + ", and " +
240-
ParsePushBroadcastReceiver.ACTION_PUSH_DELETE + ". You can do this by adding " +
241-
"these lines to your AndroidManifest.xml:\n\n" +
242-
" <receiver android:name=\"com.parse.ParsePushBroadcastReceiver\"\n" +
243-
" android:exported=false>\n" +
244-
" <intent-filter>\n" +
245-
" <action android:name=\"com.parse.push.intent.RECEIVE\" />\n" +
246-
" <action android:name=\"com.parse.push.intent.OPEN\" />\n" +
247-
" <action android:name=\"com.parse.push.intent.DELETE\" />\n" +
248-
" </intent-filter>\n" +
249-
" </receiver>");
250-
} else if (hasPushBroadcastReceiver
251-
&& hasRequiredGcmDeclarations
252-
&& !isGooglePlayServicesAvailable) {
253-
PLog.e(TAG, "Cannot use GCM for push on this device because Google Play " +
254-
"Services is not installed. Install Google Play Service from the Play Store, " +
255-
"or enable PPNS as a fallback push service." +
256-
"\nTo enable PPNS as a fallback push service on devices without Google Play " +
257-
"Service support, please include PPNS.jar in your application and " +
258-
getPpnsManifestMessage());
259-
} else if (hasPushBroadcastReceiver
260-
&& hasRequiredPpnsDeclarations
261-
&& !isPPNSAvailable) {
262-
PLog.e(TAG, "Cannot use PPNS for push on this device because PPNS is not available. " +
263-
"Include PPNS.jar in your application to use PPNS.");
253+
PLog.e(TAG, "Cannot use GCM for push because the app manifest is missing some " +
254+
"required declarations. Please " + getGcmManifestMessage());
255+
}
264256
}
265257
}
266258

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
* <pre>
6767
* &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
6868
* &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
69-
* &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
7069
* &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
7170
* &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
7271
* </pre>
@@ -77,12 +76,6 @@
7776
* <p/>
7877
* <pre>
7978
* &lt;service android:name="com.parse.PushService" /&gt;
80-
* &lt;receiver android:name="com.parse.ParseBroadcastReceiver"&gt;
81-
* &lt;intent-filter&gt;
82-
* &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
83-
* &lt;action android:name="android.intent.action.USER_PRESENT" /&gt;
84-
* &lt;/intent-filter&gt;
85-
* &lt;/receiver&gt;
8679
* &lt;receiver android:name="com.parse.ParsePushBroadcastReceiver" android:exported=false&gt;
8780
* &lt;intent-filter&gt;
8881
* &lt;action android:name="com.parse.push.intent.RECEIVE" /&gt;

0 commit comments

Comments
 (0)