title: Hide push notification if it contains specific elements
body: <p>I won't show a received push notification from appearing top notifications menu my notification if it has for example key <code>update</code>. For now if I get notification with this key, all notifications are in the notification bar. I want to not present this notifications for user.</p>
  
  <p>I'm using <code>WakefulBroadcastReceiver</code> for handle notifications like below:</p>
  
  <pre><code>public class PusherReceiver extends WakefulBroadcastReceiver {
      private boolean isAppOnForeground(Context context) {
          ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
          List&lt;ActivityManager.RunningAppProcessInfo&gt; appProcesses = activityManager.getRunningAppProcesses();
          if (appProcesses == null) 
              return false;
  
          final String packageName = context.getPackageName();
          for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
              if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND &amp;&amp; appProcess.processName.equals(packageName)) {
                  return true;
              }
          }
  
          return false;
      }
  
      public void onReceive(final Context context, Intent intent) {
          Log.i("SimpleWakefulReceiver", "Starting service @ " + SystemClock.elapsedRealtime());
          if (!isAppOnForeground((context))) {
              String pushNotificationBody = intent.getStringExtra("alert");
  
              try {
                  JSONObject notificationData = new JSONObject(pushNotificationBody);
  
                  // This is the Intent to deliver to our service.
                  Intent service = new Intent(context, BackgroundService.class);
                  // Put here your data from the json as extra in in the intent
                  service.putExtra("notification", pushNotificationBody);
  
                  Log.i("PUSH_NOTIFICATION_JSON", "RECEIVED JSON " + notificationData);
  
                  // Start the service, keeping the device awake while it is launching.
                  if (!notificationData.has("update")) {
                      startWakefulService(context, service);
                  } else {
                      // Do nothing
                  }
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
      }
  }
  </code></pre>
  
  <p>UPDATE:</p>
  
  <p>I changed project a little and with <code>Onesignal</code> and his <code>NotificationExtenderService</code>, I did something like below:</p>
  
  <pre><code>public class NotificationNotDisplayingExtender extends NotificationExtenderService {
      @Override
      protected boolean onNotificationProcessing(OSNotificationReceivedResult receivedResult) {
          String notification = receivedResult.toString();
          String notificationBody = receivedResult.payload.body;
          JSONObject notificationBodyJSON = null;
          try {
              notificationBodyJSON = new JSONObject(notificationBody);
          } catch (JSONException e) {
              e.printStackTrace();
          }
          JSONObject pushNotificationData = notificationBodyJSON;
          boolean hidden = false;
  
          if (pushNotificationData.has("update")) {
              Log.i("NOTIFICATION MANAGER", "PREVENT DISPLAY NOTIFICATION");
  
              hidden = true;
          }
  
  
          // Return true to stop the notification from displaying.
          return hidden;
      }
  }
  </code></pre>
  
  <p>And it prevent displaying notifications with update key, but now I don't receive it in my PusherReceiver to start my service. Is there easy way to send data from my <code>NotificationNotDisplayingExtender</code> receivedResult to my <code>PusherReceiver</code>? </p>
  
  <p>For now it looks like my PusherReceiver don't fire his <code>onReceive</code> method.</p>
  
  <p>Many thanks for help in advance.</p>