Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Receive notification only from SENDER_ID (#1484)
Browse files Browse the repository at this point in the history
* Add ignore sender list for android

* Receive notification only from SENDER_ID
  • Loading branch information
TVolly authored and macdonst committed Mar 8, 2017
1 parent 42f8cef commit a0d51e5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/android/com/adobe/phonegap/push/GCMIntentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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/");
}
}

0 comments on commit a0d51e5

Please sign in to comment.