Skip to content

Clean up Push warnings #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Parse/src/main/java/com/parse/GcmRegistrar.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ public Task<Void> registerAsync() {
final ParseInstallation installation = ParseInstallation.getCurrentInstallation();
// Check whether we need to send registration request, if installation does not
// have device token or local device token is stale, we need to send request.
Task<Boolean> checkTask = installation.getDeviceToken() == null ? Task.forResult(true) :
isLocalDeviceTokenStaleAsync();
Task<Boolean> checkTask = installation.getDeviceToken() == null
? Task.forResult(true)
: isLocalDeviceTokenStaleAsync();
return checkTask.onSuccessTask(new Continuation<Boolean, Task<Void>>() {
@Override
public Task<Void> then(Task<Boolean> task) throws Exception {
Expand Down
71 changes: 35 additions & 36 deletions Parse/src/main/java/com/parse/ManifestInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.content.pm.ServiceInfo;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;

import java.io.File;
import java.util.ArrayList;
Expand Down Expand Up @@ -217,50 +218,48 @@ public static PushType getPushType() {
&& hasRequiredPpnsDeclarations
&& (!hasAnyGcmSpecificDeclaration || !isGooglePlayServicesAvailable)) {
pushType = PushType.PPNS;

if (isGooglePlayServicesAvailable) {
Log.w(TAG, "Using PPNS for push even though Google Play Services is available." +
" Please " + getGcmManifestMessage());
}
} else {
pushType = PushType.NONE;

// Emit warnings if the client doesn't get push due to misconfiguration of the manifest.
if (hasAnyGcmSpecificDeclaration && !hasRequiredGcmDeclarations) {
if (hasAnyGcmSpecificDeclaration) {
if (!hasPushBroadcastReceiver) {
/* Throw an error if someone migrated from an old SDK and hasn't yet started using
* ParsePushBroadcastReceiver. */
PLog.e(TAG, "Push is currently disabled. This is probably because you migrated " +
"from an older version of Parse. This version of Parse requires your app to " +
"have a BroadcastReceiver that handles " +
ParsePushBroadcastReceiver.ACTION_PUSH_RECEIVE + ", " +
ParsePushBroadcastReceiver.ACTION_PUSH_OPEN + ", and " +
ParsePushBroadcastReceiver.ACTION_PUSH_DELETE + ". You can do this by adding " +
"these lines to your AndroidManifest.xml:\n\n" +
" <receiver android:name=\"com.parse.ParsePushBroadcastReceiver\"\n" +
" android:exported=false>\n" +
" <intent-filter>\n" +
" <action android:name=\"com.parse.push.intent.RECEIVE\" />\n" +
" <action android:name=\"com.parse.push.intent.OPEN\" />\n" +
" <action android:name=\"com.parse.push.intent.DELETE\" />\n" +
" </intent-filter>\n" +
" </receiver>");
}
if (!isGooglePlayServicesAvailable) {
PLog.e(TAG, "Cannot use GCM for push on this device because Google Play " +
"Services is not available. Install Google Play Services from the Play Store.");
}
// Emit warnings if the client doesn't get push due to misconfiguration of the manifest.
if (!hasRequiredGcmDeclarations) {
/*
* If we detect that the app has some GCM-specific declarations, but not all required
* declarations for GCM, then most likely the client means to use GCM but misconfigured
* their manifest. Log an error in this case.
*/
PLog.e(TAG, "Cannot use GCM for push because the app manifest is missing some " +
"required declarations. Please " + getGcmManifestMessage());
} else if (!hasPushBroadcastReceiver &&
(hasRequiredGcmDeclarations || hasRequiredPpnsDeclarations)) {
/* Throw an error if someone migrated from an old SDK and hasn't yet started using
* ParsePushBroadcastReceiver. */
PLog.e(TAG, "Push is currently disabled. This is probably because you migrated from " +
"an older version of Parse. This version of Parse requires your app to have a " +
"BroadcastReceiver that handles " + ParsePushBroadcastReceiver.ACTION_PUSH_RECEIVE +
", " + ParsePushBroadcastReceiver.ACTION_PUSH_OPEN + ", and " +
ParsePushBroadcastReceiver.ACTION_PUSH_DELETE + ". You can do this by adding " +
"these lines to your AndroidManifest.xml:\n\n" +
" <receiver android:name=\"com.parse.ParsePushBroadcastReceiver\"\n" +
" android:exported=false>\n" +
" <intent-filter>\n" +
" <action android:name=\"com.parse.push.intent.RECEIVE\" />\n" +
" <action android:name=\"com.parse.push.intent.OPEN\" />\n" +
" <action android:name=\"com.parse.push.intent.DELETE\" />\n" +
" </intent-filter>\n" +
" </receiver>");
} else if (hasPushBroadcastReceiver
&& hasRequiredGcmDeclarations
&& !isGooglePlayServicesAvailable) {
PLog.e(TAG, "Cannot use GCM for push on this device because Google Play " +
"Services is not installed. Install Google Play Service from the Play Store, " +
"or enable PPNS as a fallback push service." +
"\nTo enable PPNS as a fallback push service on devices without Google Play " +
"Service support, please include PPNS.jar in your application and " +
getPpnsManifestMessage());
} else if (hasPushBroadcastReceiver
&& hasRequiredPpnsDeclarations
&& !isPPNSAvailable) {
PLog.e(TAG, "Cannot use PPNS for push on this device because PPNS is not available. " +
"Include PPNS.jar in your application to use PPNS.");
PLog.e(TAG, "Cannot use GCM for push because the app manifest is missing some " +
"required declarations. Please " + getGcmManifestMessage());
}
}
}

Expand Down
12 changes: 2 additions & 10 deletions Parse/src/main/java/com/parse/PushService.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,15 @@
* <pre>
* &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
* &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
* &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
* &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
* &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
* </pre>
* <p/>
* Also, make sure that {@link ParseBroadcastReceiver}, {@link PushService}, and
* {@link ParsePushBroadcastReceiver} are declared as children of the
* <code>&lt;application&gt;</code> element:
* Also, make sure that {@link PushService} and {@link ParsePushBroadcastReceiver} are declared as
* children of the <code>&lt;application&gt;</code> element:
* <p/>
* <pre>
* &lt;service android:name="com.parse.PushService" /&gt;
* &lt;receiver android:name="com.parse.ParseBroadcastReceiver"&gt;
* &lt;intent-filter&gt;
* &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
* &lt;action android:name="android.intent.action.USER_PRESENT" /&gt;
* &lt;/intent-filter&gt;
* &lt;/receiver&gt;
* &lt;receiver android:name="com.parse.ParsePushBroadcastReceiver" android:exported=false&gt;
* &lt;intent-filter&gt;
* &lt;action android:name="com.parse.push.intent.RECEIVE" /&gt;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also remove {@link ParseBroadcastReceiver} from line 74.

Expand Down