From a0d51e54aac39b8c58e4c67080f174c0228947c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D1=83=D1=80=D1=81=D1=83=D0=BD=20=D0=93=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=BF=D0=BE=D0=B2?= Date: Thu, 9 Mar 2017 03:35:47 +0500 Subject: [PATCH] Receive notification only from SENDER_ID (#1484) * Add ignore sender list for android * Receive notification only from SENDER_ID --- .../com/adobe/phonegap/push/GCMIntentService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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/"); + } }