diff --git a/Parse/src/main/java/com/parse/GcmRegistrar.java b/Parse/src/main/java/com/parse/GcmRegistrar.java index 29a5c693a..11dd62b9d 100644 --- a/Parse/src/main/java/com/parse/GcmRegistrar.java +++ b/Parse/src/main/java/com/parse/GcmRegistrar.java @@ -96,8 +96,9 @@ public Task 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 checkTask = installation.getDeviceToken() == null ? Task.forResult(true) : - isLocalDeviceTokenStaleAsync(); + Task checkTask = installation.getDeviceToken() == null + ? Task.forResult(true) + : isLocalDeviceTokenStaleAsync(); return checkTask.onSuccessTask(new Continuation>() { @Override public Task then(Task task) throws Exception { diff --git a/Parse/src/main/java/com/parse/ManifestInfo.java b/Parse/src/main/java/com/parse/ManifestInfo.java index 4e4d07b3b..b7486f03f 100644 --- a/Parse/src/main/java/com/parse/ManifestInfo.java +++ b/Parse/src/main/java/com/parse/ManifestInfo.java @@ -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; @@ -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" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " "); + } + 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" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " "); - } 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()); + } } } diff --git a/Parse/src/main/java/com/parse/PushService.java b/Parse/src/main/java/com/parse/PushService.java index eb54cb858..4898dc61e 100644 --- a/Parse/src/main/java/com/parse/PushService.java +++ b/Parse/src/main/java/com/parse/PushService.java @@ -66,23 +66,15 @@ *
  * <uses-permission android:name="android.permission.INTERNET" />
  * <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- * <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
  * <uses-permission android:name="android.permission.VIBRATE" />
  * <uses-permission android:name="android.permission.WAKE_LOCK" />
  * 
*

- * Also, make sure that {@link ParseBroadcastReceiver}, {@link PushService}, and - * {@link ParsePushBroadcastReceiver} are declared as children of the - * <application> element: + * Also, make sure that {@link PushService} and {@link ParsePushBroadcastReceiver} are declared as + * children of the <application> element: *

*

  * <service android:name="com.parse.PushService" />
- * <receiver android:name="com.parse.ParseBroadcastReceiver">
- *   <intent-filter>
- *     <action android:name="android.intent.action.BOOT_COMPLETED" />
- *     <action android:name="android.intent.action.USER_PRESENT" />
- *   </intent-filter>
- * </receiver>
  * <receiver android:name="com.parse.ParsePushBroadcastReceiver" android:exported=false>
  *  <intent-filter>
  *     <action android:name="com.parse.push.intent.RECEIVE" />