diff --git a/src/android/com/adobe/phonegap/push/GCMIntentService.java b/src/android/com/adobe/phonegap/push/GCMIntentService.java index b1d297acd..dda5bd73d 100644 --- a/src/android/com/adobe/phonegap/push/GCMIntentService.java +++ b/src/android/com/adobe/phonegap/push/GCMIntentService.java @@ -62,7 +62,7 @@ public void setNotification(int notId, String message){ public void onMessageReceived(String from, Bundle extras) { Log.d(LOG_TAG, "onMessage - from: " + from); - if (extras != null) { + if (extras != null && isAvailableSender(from)) { Context applicationContext = getApplicationContext(); SharedPreferences prefs = applicationContext.getSharedPreferences(PushPlugin.COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE); @@ -810,4 +810,11 @@ private Spanned fromHtml(String source) { else return null; } + + private boolean isAvailableSender(String from) { + SharedPreferences sharedPref = getApplicationContext().getSharedPreferences(PushPlugin.COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE); + String savedSenderID = sharedPref.getString(SENDER_ID, ""); + + return from.equals(savedSenderID) || from.startsWith("/topics/"); + } }