|
22 | 22 | import android.content.pm.ServiceInfo;
|
23 | 23 | import android.os.Build;
|
24 | 24 | import android.os.Bundle;
|
| 25 | +import android.util.Log; |
25 | 26 |
|
26 | 27 | import java.io.File;
|
27 | 28 | import java.util.ArrayList;
|
@@ -217,50 +218,48 @@ public static PushType getPushType() {
|
217 | 218 | && hasRequiredPpnsDeclarations
|
218 | 219 | && (!hasAnyGcmSpecificDeclaration || !isGooglePlayServicesAvailable)) {
|
219 | 220 | pushType = PushType.PPNS;
|
| 221 | + |
| 222 | + if (isGooglePlayServicesAvailable) { |
| 223 | + Log.w(TAG, "Using PPNS for push even though Google Play Services is available." + |
| 224 | + " Please " + getGcmManifestMessage()); |
| 225 | + } |
220 | 226 | } else {
|
221 | 227 | pushType = PushType.NONE;
|
222 | 228 |
|
223 |
| - // Emit warnings if the client doesn't get push due to misconfiguration of the manifest. |
224 |
| - if (hasAnyGcmSpecificDeclaration && !hasRequiredGcmDeclarations) { |
| 229 | + if (hasAnyGcmSpecificDeclaration) { |
| 230 | + if (!hasPushBroadcastReceiver) { |
| 231 | + /* Throw an error if someone migrated from an old SDK and hasn't yet started using |
| 232 | + * ParsePushBroadcastReceiver. */ |
| 233 | + PLog.e(TAG, "Push is currently disabled. This is probably because you migrated " + |
| 234 | + "from an older version of Parse. This version of Parse requires your app to " + |
| 235 | + "have a BroadcastReceiver that handles " + |
| 236 | + ParsePushBroadcastReceiver.ACTION_PUSH_RECEIVE + ", " + |
| 237 | + ParsePushBroadcastReceiver.ACTION_PUSH_OPEN + ", and " + |
| 238 | + ParsePushBroadcastReceiver.ACTION_PUSH_DELETE + ". You can do this by adding " + |
| 239 | + "these lines to your AndroidManifest.xml:\n\n" + |
| 240 | + " <receiver android:name=\"com.parse.ParsePushBroadcastReceiver\"\n" + |
| 241 | + " android:exported=false>\n" + |
| 242 | + " <intent-filter>\n" + |
| 243 | + " <action android:name=\"com.parse.push.intent.RECEIVE\" />\n" + |
| 244 | + " <action android:name=\"com.parse.push.intent.OPEN\" />\n" + |
| 245 | + " <action android:name=\"com.parse.push.intent.DELETE\" />\n" + |
| 246 | + " </intent-filter>\n" + |
| 247 | + " </receiver>"); |
| 248 | + } |
| 249 | + if (!isGooglePlayServicesAvailable) { |
| 250 | + PLog.e(TAG, "Cannot use GCM for push on this device because Google Play " + |
| 251 | + "Services is not available. Install Google Play Services from the Play Store."); |
| 252 | + } |
| 253 | + // Emit warnings if the client doesn't get push due to misconfiguration of the manifest. |
| 254 | + if (!hasRequiredGcmDeclarations) { |
225 | 255 | /*
|
226 | 256 | * If we detect that the app has some GCM-specific declarations, but not all required
|
227 | 257 | * declarations for GCM, then most likely the client means to use GCM but misconfigured
|
228 | 258 | * their manifest. Log an error in this case.
|
229 | 259 | */
|
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."); |
| 260 | + PLog.e(TAG, "Cannot use GCM for push because the app manifest is missing some " + |
| 261 | + "required declarations. Please " + getGcmManifestMessage()); |
| 262 | + } |
264 | 263 | }
|
265 | 264 | }
|
266 | 265 |
|
|
0 commit comments