@@ -200,6 +200,7 @@ public static PushType getPushType() {
200
200
boolean isGooglePlayServicesAvailable = isGooglePlayServicesAvailable ();
201
201
boolean isPPNSAvailable = PPNSUtil .isPPNSAvailable ();
202
202
boolean hasAnyGcmSpecificDeclaration = hasAnyGcmSpecificDeclaration ();
203
+ boolean hasAnyPPNSSpecificDeclaration = hasAnyPPNSSpecificDeclaration ();
203
204
ManifestCheckResult gcmSupportLevel = gcmSupportLevel ();
204
205
ManifestCheckResult ppnsSupportLevel = ppnsSupportLevel ();
205
206
@@ -260,6 +261,40 @@ public static PushType getPushType() {
260
261
PLog .e (TAG , "Cannot use GCM for push because the app manifest is missing some " +
261
262
"required declarations. Please " + getGcmManifestMessage ());
262
263
}
264
+ } else if (hasAnyPPNSSpecificDeclaration ) {
265
+ PLog .w (TAG , "We find you have some PPNS specific declarations. If you are not intend " +
266
+ "to use PPNS, we highly recommend you to use GCM for push. Please check the push " +
267
+ "tutorial in our website." );
268
+ if (!hasPushBroadcastReceiver ) {
269
+ /* Throw an error if someone migrated from an old SDK and hasn't yet started using
270
+ * ParsePushBroadcastReceiver. */
271
+ PLog .e (TAG , "Push is currently disabled. This is probably because you migrated " +
272
+ "from an older version of Parse. This version of Parse requires your app to " +
273
+ "have a BroadcastReceiver that handles " +
274
+ ParsePushBroadcastReceiver .ACTION_PUSH_RECEIVE + ", " +
275
+ ParsePushBroadcastReceiver .ACTION_PUSH_OPEN + ", and " +
276
+ ParsePushBroadcastReceiver .ACTION_PUSH_DELETE + ". You can do this by adding " +
277
+ "these lines to your AndroidManifest.xml:\n \n " +
278
+ " <receiver android:name=\" com.parse.ParsePushBroadcastReceiver\" \n " +
279
+ " android:exported=false>\n " +
280
+ " <intent-filter>\n " +
281
+ " <action android:name=\" com.parse.push.intent.RECEIVE\" />\n " +
282
+ " <action android:name=\" com.parse.push.intent.OPEN\" />\n " +
283
+ " <action android:name=\" com.parse.push.intent.DELETE\" />\n " +
284
+ " </intent-filter>\n " +
285
+ " </receiver>" );
286
+ }
287
+ if (!isPPNSAvailable ) {
288
+ PLog .e (TAG , "Cannot use PPNS for push on this device. Make sure you add PPNS.jar as" +
289
+ " your dependency." );
290
+ }
291
+ if (!hasRequiredPpnsDeclarations ) {
292
+ PLog .e (TAG , "Cannot use PPNS for push because the app manifest is missing some " +
293
+ "required declarations. Please " + getPpnsManifestMessage ());
294
+ }
295
+ } else {
296
+ PLog .e (TAG , "Push is currently disabled. If you want to use push, please check the " +
297
+ "push tutorial in our website." );
263
298
}
264
299
}
265
300
@@ -269,16 +304,14 @@ public static PushType getPushType() {
269
304
* If we selected gcm/ppns but the manifest is missing some optional declarations, warn so
270
305
* the user knows how to add those optional declarations.
271
306
*/
272
- if (Parse .getLogLevel () <= Parse .LOG_LEVEL_WARNING ) {
273
- if (pushType == PushType .GCM && gcmSupportLevel == ManifestCheckResult .MISSING_OPTIONAL_DECLARATIONS ) {
274
- PLog .w (TAG , "Using GCM for Parse Push, but the app manifest is missing some optional " +
275
- "declarations that should be added for maximum reliability. Please " +
276
- getGcmManifestMessage ());
277
- } else if (pushType == PushType .PPNS && ppnsSupportLevel == ManifestCheckResult .MISSING_OPTIONAL_DECLARATIONS ) {
278
- PLog .w (TAG , "Using PPNS for push, but the app manifest is missing some optional " +
279
- "declarations that should be added for maximum reliability. Please " +
280
- getPpnsManifestMessage ());
281
- }
307
+ if (pushType == PushType .GCM && gcmSupportLevel == ManifestCheckResult .MISSING_OPTIONAL_DECLARATIONS ) {
308
+ PLog .w (TAG , "Using GCM for Parse Push, but the app manifest is missing some optional " +
309
+ "declarations that should be added for maximum reliability. Please " +
310
+ getGcmManifestMessage ());
311
+ } else if (pushType == PushType .PPNS && ppnsSupportLevel == ManifestCheckResult .MISSING_OPTIONAL_DECLARATIONS ) {
312
+ PLog .w (TAG , "Using PPNS for push, but the app manifest is missing some optional " +
313
+ "declarations that should be added for maximum reliability. Please " +
314
+ getPpnsManifestMessage ());
282
315
}
283
316
}
284
317
}
@@ -459,6 +492,16 @@ private static boolean hasAnyGcmSpecificDeclaration() {
459
492
return false ;
460
493
}
461
494
495
+ private static boolean hasAnyPPNSSpecificDeclaration () {
496
+ Context context = getContext ();
497
+ if (hasRequestedPermissions (context , "android.permission.RECEIVE_BOOT_COMPLETED" ) ||
498
+ getReceiverInfo (ParseBroadcastReceiver .class ) != null ) {
499
+ return true ;
500
+ }
501
+
502
+ return false ;
503
+ }
504
+
462
505
private static boolean isGooglePlayServicesAvailable () {
463
506
return Build .VERSION .SDK_INT >= 8 && getPackageInfo ("com.google.android.gsf" ) != null ;
464
507
}
@@ -546,7 +589,7 @@ private static String getGcmManifestMessage() {
546
589
String packageName = getContext ().getPackageName ();
547
590
String gcmPackagePermission = packageName + ".permission.C2D_MESSAGE" ;
548
591
return "make sure that these permissions are declared as children " +
549
- "of the root <manifest> element:\n " +
592
+ "of the root <manifest> element:\n " +
550
593
"\n " +
551
594
"<uses-permission android:name=\" android.permission.INTERNET\" />\n " +
552
595
"<uses-permission android:name=\" android.permission.ACCESS_NETWORK_STATE\" />\n " +
0 commit comments