|
|
@@ -174,6 +174,15 @@ public class LocalNotification extends CordovaPlugin {
|
|
|
else if (action.equals("getTriggeredIds")) {
|
|
|
getTriggeredIds(command);
|
|
|
}
|
|
|
+ else if (action.equals("getSingle")) {
|
|
|
+ getSingle(args, command);
|
|
|
+ }
|
|
|
+ else if (action.equals("getSingleScheduled")) {
|
|
|
+ getSingleScheduled(args, command);
|
|
|
+ }
|
|
|
+ else if (action.equals("getSingleTriggered")) {
|
|
|
+ getSingleTriggered(args, command);
|
|
|
+ }
|
|
|
else if (action.equals("getAll")) {
|
|
|
getAll(args, command);
|
|
|
}
|
|
|
@@ -369,23 +378,51 @@ public class LocalNotification extends CordovaPlugin {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Set of options from local notification.
|
|
|
+ * Options from local notification.
|
|
|
*
|
|
|
* @param ids
|
|
|
* Set of local notification IDs
|
|
|
* @param command
|
|
|
* The callback context used when calling back into JavaScript.
|
|
|
*/
|
|
|
- private void getAll (JSONArray ids, CallbackContext command) {
|
|
|
- List<JSONObject> options;
|
|
|
+ private void getSingle (JSONArray ids, CallbackContext command) {
|
|
|
+ getOptions(ids.optString(0), Notification.Type.ALL, command);
|
|
|
+ }
|
|
|
|
|
|
- if (ids.length() == 0) {
|
|
|
- options = getNotificationMgr().getOptions();
|
|
|
- } else {
|
|
|
- options = getNotificationMgr().getOptionsById(toList(ids));
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * Options from scheduled notification.
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * Set of local notification IDs
|
|
|
+ * @param command
|
|
|
+ * The callback context used when calling back into JavaScript.
|
|
|
+ */
|
|
|
+ private void getSingleScheduled (JSONArray ids, CallbackContext command) {
|
|
|
+ getOptions(ids.optString(0), Notification.Type.SCHEDULED, command);
|
|
|
+ }
|
|
|
|
|
|
- command.success(new JSONArray(options));
|
|
|
+ /**
|
|
|
+ * Options from triggered notification.
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * Set of local notification IDs
|
|
|
+ * @param command
|
|
|
+ * The callback context used when calling back into JavaScript.
|
|
|
+ */
|
|
|
+ private void getSingleTriggered (JSONArray ids, CallbackContext command) {
|
|
|
+ getOptions(ids.optString(0), Notification.Type.TRIGGERED, command);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Set of options from local notification.
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * Set of local notification IDs
|
|
|
+ * @param command
|
|
|
+ * The callback context used when calling back into JavaScript.
|
|
|
+ */
|
|
|
+ private void getAll (JSONArray ids, CallbackContext command) {
|
|
|
+ getOptions(ids, Notification.Type.ALL, command);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -397,16 +434,7 @@ public class LocalNotification extends CordovaPlugin {
|
|
|
* The callback context used when calling back into JavaScript.
|
|
|
*/
|
|
|
private void getScheduled (JSONArray ids, CallbackContext command) {
|
|
|
- List<JSONObject> options;
|
|
|
-
|
|
|
- if (ids.length() == 0) {
|
|
|
- options = getNotificationMgr().getOptionsByType(Notification.Type.SCHEDULED);
|
|
|
- } else {
|
|
|
- options = getNotificationMgr().getOptionsBy(
|
|
|
- Notification.Type.SCHEDULED, toList(ids));
|
|
|
- }
|
|
|
-
|
|
|
- command.success(new JSONArray(options));
|
|
|
+ getOptions(ids, Notification.Type.SCHEDULED, command);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -418,13 +446,49 @@ public class LocalNotification extends CordovaPlugin {
|
|
|
* The callback context used when calling back into JavaScript.
|
|
|
*/
|
|
|
private void getTriggered (JSONArray ids, CallbackContext command) {
|
|
|
+ getOptions(ids, Notification.Type.TRIGGERED, command);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Options from local notification.
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * Set of local notification IDs
|
|
|
+ * @param type
|
|
|
+ * The local notification life cycle type
|
|
|
+ * @param command
|
|
|
+ * The callback context used when calling back into JavaScript.
|
|
|
+ */
|
|
|
+ private void getOptions (String id, Notification.Type type,
|
|
|
+ CallbackContext command) {
|
|
|
+
|
|
|
+ JSONArray ids = new JSONArray().put(id);
|
|
|
+
|
|
|
+ JSONObject options =
|
|
|
+ getNotificationMgr().getOptionsBy(type, toList(ids)).get(0);
|
|
|
+
|
|
|
+ command.success(options);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Set of options from local notifications.
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * Set of local notification IDs
|
|
|
+ * @param type
|
|
|
+ * The local notification life cycle type
|
|
|
+ * @param command
|
|
|
+ * The callback context used when calling back into JavaScript.
|
|
|
+ */
|
|
|
+ private void getOptions (JSONArray ids, Notification.Type type,
|
|
|
+ CallbackContext command) {
|
|
|
+
|
|
|
List<JSONObject> options;
|
|
|
|
|
|
if (ids.length() == 0) {
|
|
|
- options = getNotificationMgr().getOptionsByType(Notification.Type.TRIGGERED);
|
|
|
+ options = getNotificationMgr().getOptionsByType(type);
|
|
|
} else {
|
|
|
- options = getNotificationMgr().getOptionsBy(
|
|
|
- Notification.Type.TRIGGERED, toList(ids));
|
|
|
+ options = getNotificationMgr().getOptionsBy(type, toList(ids));
|
|
|
}
|
|
|
|
|
|
command.success(new JSONArray(options));
|