/**
   * Cancel all notifications that were created by this plugin.
   *
   * <p>Android can only unregister a specific alarm. There is no such thing as cancelAll. Therefore
   * we rely on the Shared Preferences which holds all our alarms to loop through these alarms and
   * unregister them one by one.
   */
  public static void cancelAll() {
    SharedPreferences settings = getSharedPreferences();
    NotificationManager nc = getNotificationManager();
    Map<String, ?> alarms = settings.getAll();
    Set<String> alarmIds = alarms.keySet();

    for (String alarmId : alarmIds) {
      cancel(alarmId);
    }

    nc.cancelAll();
  }
  @Override
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext)
      throws JSONException {
    LocalNotification.webView = super.webView;
    LocalNotification.context = super.cordova.getActivity().getApplicationContext();

    if (action.equalsIgnoreCase("add")) {
      JSONObject arguments = args.optJSONObject(0);
      final Options options = new Options(context).parse(arguments);

      persist(options.getId(), args);

      cordova
          .getThreadPool()
          .execute(
              new Runnable() {
                public void run() {
                  add(options);
                }
              });

      return true;
    }

    if (action.equalsIgnoreCase("cancel")) {
      String id = args.optString(0);

      cancel(id);
      unpersist(id);

      return true;
    }

    if (action.equalsIgnoreCase("cancelAll")) {
      cancelAll();
      unpersistAll();

      return true;
    }

    // Returning false results in a "MethodNotFound" error.
    return false;
  }