Explorar el Código

Internal code changes

Sebastián Katzer hace 7 años
padre
commit
f2fb5e10e8

+ 127 - 143
src/android/LocalNotification.java

@@ -141,52 +141,34 @@ public class LocalNotification extends CordovaPlugin {
                     actions(args, command);
                 } else
                 if (action.equals("schedule")) {
-                    schedule(args);
-                    check(command);
+                    schedule(args, command);
                 } else
                 if (action.equals("update")) {
-                    update(args);
-                    check(command);
+                    update(args, command);
                 } else
                 if (action.equals("cancel")) {
-                    cancel(args);
-                    command.success();
+                    cancel(args, command);
                 } else
                 if (action.equals("cancelAll")) {
-                    cancelAll();
-                    command.success();
+                    cancelAll(command);
                 } else
                 if (action.equals("clear")) {
-                    clear(args);
-                    command.success();
+                    clear(args, command);
                 } else
                 if (action.equals("clearAll")) {
-                    clearAll();
-                    command.success();
+                    clearAll(command);
                 } else
                 if (action.equals("type")) {
-                    type(args.optInt(0), command);
+                    type(args, command);
                 } else
                 if (action.equals("ids")) {
-                    ids(command);
-                } else
-                if (action.equals("scheduledIds")) {
-                    scheduledIds(command);
-                } else
-                if (action.equals("triggeredIds")) {
-                    triggeredIds(command);
+                    ids(args, command);
                 } else
                 if (action.equals("notification")) {
-                    notification(args.optInt(0), command);
+                    notification(args, command);
                 } else
                 if (action.equals("notifications")) {
                     notifications(args, command);
-                } else
-                if (action.equals("scheduledNotifications")) {
-                    scheduledNotifications(command);
-                } else
-                if (action.equals("triggeredNotifications")) {
-                    triggeredNotifications(command);
                 }
             }
         });
@@ -248,35 +230,23 @@ public class LocalNotification extends CordovaPlugin {
      *                JavaScript.
      */
     private void actions (JSONArray args, CallbackContext command) {
-        int task = args.optInt(0);
-
-        ActionGroup group;
-        JSONObject spec;
-        boolean found;
-        String id;
+        int task        = args.optInt(0);
+        String id       = args.optString(1);
+        JSONObject spec = args.optJSONObject(2);
 
         switch (task) {
-            case 1:
-                spec  = args.optJSONObject(1);
-                group = ActionGroup.parse(cordova.getActivity(), spec);
-
+            case 0:
+                ActionGroup group = ActionGroup.parse(cordova.getActivity(), spec);
                 if (group != null) ActionGroup.register(group);
                 command.success();
-
                 break;
-            case -1:
-                id = args.optString(1);
-
+            case 1:
                 ActionGroup.unregister(id);
                 command.success();
-
                 break;
-            case 0:
-                id = args.optString(1);
-
-                found = ActionGroup.isRegistered(id);
+            case 2:
+                boolean found = ActionGroup.isRegistered(id);
                 success(command, found);
-
                 break;
         }
     }
@@ -284,107 +254,130 @@ public class LocalNotification extends CordovaPlugin {
     /**
      * Schedule multiple local notifications.
      *
-     * @param notifications The notifications to schedule.
+     * @param toasts  The notifications to schedule.
+     * @param command The callback context used when calling back into
+     *                JavaScript.
      */
-    private void schedule (JSONArray notifications) {
+    private void schedule (JSONArray toasts, CallbackContext command) {
         Manager mgr = getNotMgr();
 
-        for (int i = 0; i < notifications.length(); i++) {
-            JSONObject dict = notifications.optJSONObject(i);
-            Options options = new Options(dict);
-            Request request = new Request(options);
-
-            Notification notification =
-                    mgr.schedule(request, TriggerReceiver.class);
+        for (int i = 0; i < toasts.length(); i++) {
+            JSONObject dict    = toasts.optJSONObject(i);
+            Options options    = new Options(dict);
+            Request request    = new Request(options);
+            Notification toast = mgr.schedule(request, TriggerReceiver.class);
 
-            if (notification != null) {
-                fireEvent("add", notification);
+            if (toast != null) {
+                fireEvent("add", toast);
             }
         }
+
+        check(command);
     }
 
     /**
      * Update multiple local notifications.
      *
-     * @param updates Notification properties including their IDs
+     * @param updates Notification properties including their IDs.
+     * @param command The callback context used when calling back into
+     *                JavaScript.
      */
-    private void update (JSONArray updates) {
-        for (int i = 0; i < updates.length(); i++) {
-            JSONObject update = updates.optJSONObject(i);
-            int id            = update.optInt("id", 0);
+    private void update (JSONArray updates, CallbackContext command) {
+        Manager mgr = getNotMgr();
 
-            Notification notification =
-                    getNotMgr().update(id, update, TriggerReceiver.class);
+        for (int i = 0; i < updates.length(); i++) {
+            JSONObject update  = updates.optJSONObject(i);
+            int id             = update.optInt("id", 0);
+            Notification toast = mgr.update(id, update, TriggerReceiver.class);
 
-            if (notification == null)
+            if (toast == null)
                 continue;
 
-            fireEvent("update", notification);
+            fireEvent("update", toast);
         }
+
+        check(command);
     }
 
     /**
      * Cancel multiple local notifications.
      *
-     * @param ids Set of local notification IDs
+     * @param ids     Set of local notification IDs.
+     * @param command The callback context used when calling back into
+     *                JavaScript.
      */
-    private void cancel (JSONArray ids) {
-        for (int i = 0; i < ids.length(); i++) {
-            int id = ids.optInt(i, 0);
+    private void cancel (JSONArray ids, CallbackContext command) {
+        Manager mgr = getNotMgr();
 
-            Notification notification =
-                    getNotMgr().cancel(id);
+        for (int i = 0; i < ids.length(); i++) {
+            int id             = ids.optInt(i, 0);
+            Notification toast = mgr.cancel(id);
 
-            if (notification == null)
+            if (toast == null)
                 continue;
 
-            fireEvent("cancel", notification);
+            fireEvent("cancel", toast);
         }
+
+        command.success();
     }
 
     /**
      * Cancel all scheduled notifications.
+     *
+     * @param command The callback context used when calling back into
+     *                JavaScript.
      */
-    private void cancelAll() {
+    private void cancelAll(CallbackContext command) {
         getNotMgr().cancelAll();
         fireEvent("cancelall");
+        command.success();
     }
 
     /**
      * Clear multiple local notifications without canceling them.
      *
-     * @param ids Set of local notification IDs
+     * @param ids     Set of local notification IDs.
+     * @param command The callback context used when calling back into
+     *                JavaScript.
      */
-    private void clear(JSONArray ids){
-        for (int i = 0; i < ids.length(); i++) {
-            int id = ids.optInt(i, 0);
+    private void clear(JSONArray ids, CallbackContext command) {
+        Manager mgr = getNotMgr();
 
-            Notification notification =
-                    getNotMgr().clear(id);
+        for (int i = 0; i < ids.length(); i++) {
+            int id             = ids.optInt(i, 0);
+            Notification toast = mgr.clear(id);
 
-            if (notification == null)
+            if (toast == null)
                 continue;
 
-            fireEvent("clear", notification);
+            fireEvent("clear", toast);
         }
+
+        command.success();
     }
 
     /**
      * Clear all triggered notifications without canceling them.
+     *
+     * @param command The callback context used when calling back into
+     *                JavaScript.
      */
-    private void clearAll() {
+    private void clearAll(CallbackContext command) {
         getNotMgr().clearAll();
         fireEvent("clearall");
+        command.success();
     }
 
     /**
      * Get the type of the notification (unknown, scheduled, triggered).
      *
-     * @param id      The ID of the notification to check.
+     * @param args    The exec() arguments in JSON form.
      * @param command The callback context used when calling back into
      *                JavaScript.
      */
-    private void type (int id, CallbackContext command) {
+    private void type (JSONArray args, CallbackContext command) {
+        int id             = args.optInt(0);
         Notification toast = getNotMgr().get(id);
 
         if (toast == null) {
@@ -408,48 +401,46 @@ public class LocalNotification extends CordovaPlugin {
     /**
      * Set of IDs from all existent notifications.
      *
+     * @param args    The exec() arguments in JSON form.
      * @param command The callback context used when calling back into
      *                JavaScript.
      */
-    private void ids (CallbackContext command) {
-        List<Integer> ids = getNotMgr().getIds();
-        command.success(new JSONArray(ids));
-    }
+    private void ids (JSONArray args, CallbackContext command) {
+        int type    = args.optInt(0);
+        Manager mgr = getNotMgr();
+        List<Integer> ids;
 
-    /**
-     * Set of IDs from all scheduled notifications.
-     *
-     * @param command The callback context used when calling back into
-     *                JavaScript.
-     */
-    private void scheduledIds (CallbackContext command) {
-        List<Integer> ids = getNotMgr().getIdsByType(SCHEDULED);
-        command.success(new JSONArray(ids));
-    }
+        switch (type) {
+            case 0:
+                ids = mgr.getIds();
+                break;
+            case 1:
+                ids = mgr.getIdsByType(SCHEDULED);
+                break;
+            case 2:
+                ids = mgr.getIdsByType(TRIGGERED);
+                break;
+            default:
+                ids = new ArrayList<Integer>(0);
+                break;
+        }
 
-    /**
-     * Set of IDs from all triggered notifications.
-     *
-     * @param command The callback context used when calling back into
-     *                JavaScript.
-     */
-    private void triggeredIds (CallbackContext command) {
-        List<Integer> ids = getNotMgr().getIdsByType(TRIGGERED);
         command.success(new JSONArray(ids));
     }
 
     /**
      * Options from local notification.
      *
-     * @param id      The ID of the notification.
+     * @param args    The exec() arguments in JSON form.
      * @param command The callback context used when calling back into
      *                JavaScript.
      */
-    private void notification (int id, CallbackContext command) {
-        Options options = getNotMgr().getOptions(id);
+    private void notification (JSONArray args, CallbackContext command) {
+        int id       = args.optInt(0);
+        Options opts = getNotMgr().getOptions(id);
 
-        if (options != null) {
-            command.success(options.getDict());
+        if (opts != null) {
+            command.success(opts.getDict());
         } else {
             command.success();
         }
@@ -458,48 +449,41 @@ public class LocalNotification extends CordovaPlugin {
     /**
      * Set of options from local notification.
      *
-     * @param ids     Set of local notification IDs.
+     * @param args    The exec() arguments in JSON form.
      * @param command The callback context used when calling back into
      *                JavaScript.
      */
-    private void notifications (JSONArray ids, CallbackContext command) {
+    private void notifications (JSONArray args, CallbackContext command) {
+        int type      = args.optInt(0);
+        JSONArray ids = args.optJSONArray(1);
+        Manager mgr   = getNotMgr();
         List<JSONObject> options;
 
-        if (ids.length() == 0) {
-            options = getNotMgr().getOptions();
-        } else {
-            options = getNotMgr().getOptionsById(toList(ids));
+        switch (type) {
+            case 0:
+                options = mgr.getOptions();
+                break;
+            case 1:
+                options = mgr.getOptionsByType(SCHEDULED);
+                break;
+            case 2:
+                options = mgr.getOptionsByType(TRIGGERED);
+                break;
+            case 3:
+                options = mgr.getOptionsById(toList(ids));
+                break;
+            default:
+                options = new ArrayList<JSONObject>(0);
+                break;
         }
 
         command.success(new JSONArray(options));
     }
 
-    /**
-     * Set of options from scheduled notifications.
-     *
-     * @param command The callback context used when calling back into
-     *                JavaScript.
-     */
-    private void scheduledNotifications (CallbackContext command) {
-        List<JSONObject> options = getNotMgr().getOptionsByType(SCHEDULED);
-        command.success(new JSONArray(options));
-    }
-
-    /**
-     * Set of options from triggered notifications.
-     *
-     * @param command The callback context used when calling back into
-     *                JavaScript.
-     */
-    private void triggeredNotifications (CallbackContext command) {
-        List<JSONObject> options = getNotMgr().getOptionsByType(TRIGGERED);
-        command.success(new JSONArray(options));
-    }
-
     /**
      * Call all pending callbacks after the deviceready event has been fired.
      */
-    private static synchronized void deviceready () {
+    private static synchronized void deviceready() {
         deviceready = true;
 
         for (String js : eventQueue) {

+ 4 - 26
src/ios/APPLocalNotification.h

@@ -25,50 +25,28 @@
 
 @interface APPLocalNotification : CDVPlugin <UNUserNotificationCenterDelegate>
 
-// Set launchDetails object
 - (void) launch:(CDVInvokedUrlCommand*)command;
-// Execute all queued events
 - (void) ready:(CDVInvokedUrlCommand*)command;
 
-// Check permission to show notifications
+- (void) actions:(CDVInvokedUrlCommand*)command;
+
 - (void) check:(CDVInvokedUrlCommand*)command;
-// Request permission to show notifications
 - (void) request:(CDVInvokedUrlCommand*)command;
 
-// Register/update an action group
-- (void) actions:(CDVInvokedUrlCommand*)command;
-
-// Schedule notifications
 - (void) schedule:(CDVInvokedUrlCommand*)command;
-// Update set of notifications
 - (void) update:(CDVInvokedUrlCommand*)command;
-// Clear notifications by id
+
 - (void) clear:(CDVInvokedUrlCommand*)command;
-// Clear all notifications
 - (void) clearAll:(CDVInvokedUrlCommand*)command;
-// Cancel notifications by id
+
 - (void) cancel:(CDVInvokedUrlCommand*)command;
-// Cancel all notifications
 - (void) cancelAll:(CDVInvokedUrlCommand*)command;
 
-// Notification type
 - (void) type:(CDVInvokedUrlCommand*)command;
 
-// List of all notification IDs
 - (void) ids:(CDVInvokedUrlCommand*)command;
-// List of all scheduled notification IDs
-- (void) scheduledIds:(CDVInvokedUrlCommand*)command;
-// List of all triggered notification IDs
-- (void) triggeredIds:(CDVInvokedUrlCommand*)command;
 
-// Notification by id
 - (void) notification:(CDVInvokedUrlCommand*)command;
-
-// List of notifications by id
 - (void) notifications:(CDVInvokedUrlCommand*)command;
-// List of scheduled notifications by id
-- (void) scheduledNotifications:(CDVInvokedUrlCommand*)command;
-// List of triggered notifications by id
-- (void) triggeredNotifications:(CDVInvokedUrlCommand*)command;
 
 @end

+ 53 - 101
src/ios/APPLocalNotification.m

@@ -258,52 +258,34 @@ UNNotificationPresentationOptions const OptionAlert = UNNotificationPresentation
 }
 
 /**
- * List of all notification IDs.
+ * List of notification IDs by type.
  *
  * @return [ Void ]
  */
 - (void) ids:(CDVInvokedUrlCommand*)command
-{
-    [self ids:command byType:NotifcationTypeAll];
-}
-
-/**
- * List of all scheduled notification IDs.
- *
- * @return [ Void ]
- */
-- (void) scheduledIds:(CDVInvokedUrlCommand*)command
-{
-    [self ids:command byType:NotifcationTypeScheduled];
-}
-
-/**
- * List of all triggered notification IDs.
- *
- * @return [ Void ]
- */
-- (void) triggeredIds:(CDVInvokedUrlCommand*)command
-{
-    [self ids:command byType:NotifcationTypeTriggered];
-}
-
-/**
- * List of ids for given local notifications.
- *
- * @param [ APPNotificationType ] type The type of notifications to look for.
- *
- * @return [ Void ]
- */
-- (void) ids:(CDVInvokedUrlCommand*)command
-      byType:(APPNotificationType)type;
 {
     [self.commandDelegate runInBackground:^{
+        int code                 = [command.arguments[0] intValue];
+        APPNotificationType type = NotifcationTypeUnknown;
+        
+        switch (code) {
+            case 0:
+                type = NotifcationTypeAll;
+                break;
+            case 1:
+                type = NotifcationTypeScheduled;
+                break;
+            case 2:
+                type = NotifcationTypeTriggered;
+                break;
+        }
+        
         NSArray* ids = [_center getNotificationIdsByType:type];
-
+        
         CDVPluginResult* result;
         result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
                                     messageAsArray:ids];
-
+        
         [self.commandDelegate sendPluginResult:result
                                     callbackId:command.callbackId];
     }];
@@ -341,59 +323,37 @@ UNNotificationPresentationOptions const OptionAlert = UNNotificationPresentation
  * @return [ Void ]
  */
 - (void) notifications:(CDVInvokedUrlCommand*)command
-{
-    [self notifications:command byType:NotifcationTypeAll];
-}
-
-/**
- * List of scheduled notifications by id.
- *
- * @param [ Array<Number> ] ids The ids of the notifications to return.
- *
- * @return [ Void ]
- */
-- (void) scheduledNotifications:(CDVInvokedUrlCommand*)command
-{
-    [self notifications:command byType:NotifcationTypeScheduled];
-}
-
-/**
- * List of triggered notifications by id.
- *
- * @param [ Array<Number> ] ids The ids of the notifications to return.
- *
- * @return [ Void ]
- */
-- (void) triggeredNotifications:(CDVInvokedUrlCommand *)command
-{
-    [self notifications:command byType:NotifcationTypeTriggered];
-}
-
-/**
- * List of notifications by type or id.
- *
- * @param [ APPNotificationType ] type The type of notifications to look for.
- *
- * @return [ Void ]
- */
-- (void) notifications:(CDVInvokedUrlCommand*)command
-                byType:(APPNotificationType)type;
 {
     [self.commandDelegate runInBackground:^{
-        NSArray* ids = command.arguments;
-        NSArray* notifications;
-
-        if (ids.count > 0) {
-            notifications = [_center getNotificationOptionsById:ids];
+        int code                 = [command.arguments[0] intValue];
+        APPNotificationType type = NotifcationTypeUnknown;
+        NSArray* toasts;
+        NSArray* ids;
+        
+        switch (code) {
+            case 0:
+                type = NotifcationTypeAll;
+                break;
+            case 1:
+                type = NotifcationTypeScheduled;
+                break;
+            case 2:
+                type = NotifcationTypeTriggered;
+                break;
+            case 3:
+                ids    = command.arguments[1];
+                toasts = [_center getNotificationOptionsById:ids];
+                break;
         }
-        else {
-            notifications = [_center getNotificationOptionsByType:type];
+        
+        if (toasts == nil) {
+            toasts = [_center getNotificationOptionsByType:type];
         }
-
+        
         CDVPluginResult* result;
         result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
-                                    messageAsArray:notifications];
-
+                                    messageAsArray:toasts];
+        
         [self.commandDelegate sendPluginResult:result
                                     callbackId:command.callbackId];
     }];
@@ -438,35 +398,27 @@ UNNotificationPresentationOptions const OptionAlert = UNNotificationPresentation
 - (void) actions:(CDVInvokedUrlCommand *)command
 {
     [self.commandDelegate runInBackground:^{
-        int task              = [command.arguments[0] intValue];
+        int code              = [command.arguments[0] intValue];
+        NSString* identifier  = [command argumentAtIndex:1];
+        NSDictionary* options = [command argumentAtIndex:2];
         APPNotificationContent* notification;
-        NSDictionary* options;
-        NSString* identifier;
         BOOL found;
-
-        switch (task) {
-            case 1:
-                options      = command.arguments[1];
+        
+        switch (code) {
+            case 0:
                 notification = [[APPNotificationContent alloc]
                                 initWithOptions:options];
-
+                
                 [_center addActionGroup:notification.category];
                 [self execCallback:command];
-
                 break;
-            case -1:
-                identifier = command.arguments[1];
-
+            case 1:
                 [_center removeActionGroup:identifier];
                 [self execCallback:command];
-
                 break;
-            case 0:
-                identifier = command.arguments[1];
-
+            case 2:
                 found = [_center hasActionGroup:identifier];
                 [self execCallback:command arg:found];
-
                 break;
         }
     }];
@@ -667,7 +619,7 @@ UNNotificationPresentationOptions const OptionAlert = UNNotificationPresentation
     CDVPluginResult *result = [CDVPluginResult
                                resultWithStatus:CDVCommandStatus_OK
                                messageAsBool:arg];
-
+    
     [self.commandDelegate sendPluginResult:result
                                 callbackId:command.callbackId];
 }

+ 46 - 25
src/ios/UNUserNotificationCenter+APPLocalNotification.m

@@ -106,7 +106,7 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
  *
  * @param [ NSString* ] identifier The category id to check for.
  *
- * @return [ Void ]
+ * @return [ BOOL ]
  */
 - (BOOL) hasActionGroup:(NSString*)identifier
 {
@@ -134,6 +134,8 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 
 /**
  * List of all delivered or still pending notifications.
+ *
+ * @return [ NSArray<UNNotificationRequest*>* ]
  */
 - (NSArray*) getNotifications
 {
@@ -147,6 +149,8 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 
 /**
  * List of all triggered notifications.
+ *
+ * @return [ NSArray<UNNotificationRequest*>* ]
  */
 - (NSArray*) getDeliveredNotifications
 {
@@ -168,6 +172,8 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 
 /**
  * List of all pending notifications.
+ *
+ * @return [ NSArray<UNNotificationRequest*>* ]
  */
 - (NSArray*) getPendingNotifications
 {
@@ -187,8 +193,9 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 /**
  * List of all notifications from given type.
  *
- * @param type
- *      Notification life cycle type
+ * @param [ APPNotificationType ] type Notification life cycle type.
+ *
+ * @return [ NSArray<UNNotificationRequest>* ]
  */
 - (NSArray*) getNotificationsByType:(APPNotificationType)type
 {
@@ -206,6 +213,8 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 
 /**
  * List of all local notifications IDs.
+ *
+ * @return [ NSArray<int>* ]
  */
 - (NSArray*) getNotificationIds
 {
@@ -223,8 +232,9 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 /**
  * List of all notifications IDs from given type.
  *
- * @param type
- *      Notification life cycle type
+ * @param [ APPNotificationType ] type Notification life cycle type.
+ *
+ * @return [ NSArray<int>* ]
  */
 - (NSArray*) getNotificationIdsByType:(APPNotificationType)type
 {
@@ -242,8 +252,9 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 /**
  * Find notification by ID.
  *
- * @param id
- *      Notification ID
+ * @param id Notification ID
+ *
+ * @return [ UNNotificationRequest* ]
  */
 - (UNNotificationRequest*) getNotificationWithId:(NSNumber*)id
 {
@@ -262,7 +273,11 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 }
 
 /**
- * Find notification type by ID
+ * Find notification type by ID.
+ *
+ * @param [ NSNumber* ] id The ID of the notification.
+ *
+ * @return [ APPNotificationType ]
  */
 - (APPNotificationType) getTypeOfNotificationWithId:(NSNumber*)id
 {
@@ -281,6 +296,8 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 
 /**
  * List of properties from all notifications.
+ *
+ * @return [ NSArray<APPNotificationOptions*>* ]
  */
 - (NSArray*) getNotificationOptions
 {
@@ -290,8 +307,9 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 /**
  * List of properties from all notifications of given type.
  *
- * @param type
- *      Notification life cycle type
+ * @param [ APPNotificationType ] type Notification life cycle type.
+ *
+ * @return [ NSArray<APPNotificationOptions*>* ]
  */
 - (NSArray*) getNotificationOptionsByType:(APPNotificationType)type
 {
@@ -309,8 +327,9 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 /**
  * List of properties from given local notifications.
  *
- * @param ids
- *      Notification IDs
+ * @param [ NSArray<int> ] ids The ids of the notifications to find.
+ *
+ * @return [ NSArray<APPNotificationOptions*>* ]
  */
 - (NSArray*) getNotificationOptionsById:(NSArray*)ids
 {
@@ -329,6 +348,8 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 
 /*
  * Clear all notfications.
+ *
+ * @return [ Void ]
  */
 - (void) clearNotifications
 {
@@ -338,19 +359,19 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 /*
  * Clear Specified notfication.
  *
- * @param notification
- *      The notification object
+ * @param [ UNNotificationRequest* ] notification The notification object.
+ *
+ * @return [ Void ]
  */
-- (void) clearNotification:(UNNotificationRequest*)notification
+- (void) clearNotification:(UNNotificationRequest*)toast
 {
-    NSArray* ids = [[NSArray alloc]
-                    initWithObjects:notification.identifier, nil];
-
-    [self removeDeliveredNotificationsWithIdentifiers:ids];
+    [self removeDeliveredNotificationsWithIdentifiers:@[toast.identifier]];
 }
 
 /*
  * Cancel all notfications.
+ *
+ * @return [ Void ]
  */
 - (void) cancelNotifications
 {
@@ -361,14 +382,14 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
 /*
  * Cancel specified notfication.
  *
- * @param notification
- *      The notification object
+ * @param [ UNNotificationRequest* ] notification The notification object.
+ *
+ * @return [ Void ]
  */
-- (void) cancelNotification:(UNNotificationRequest*)notification
+- (void) cancelNotification:(UNNotificationRequest*)toast
 {
-    NSArray* ids = [[NSArray alloc]
-                    initWithObjects:notification.identifier, nil];
-
+    NSArray* ids = @[toast.identifier];
+                    
     [self removeDeliveredNotificationsWithIdentifiers:ids];
     [self removePendingNotificationRequestsWithIdentifiers:ids];
 }

+ 10 - 10
www/local-notification.js

@@ -292,7 +292,7 @@ exports.getType = function (id, callback, scope) {
  * @return [ Void ]
  */
 exports.getIds = function (callback, scope) {
-    this._exec('ids', null, callback, scope);
+    this._exec('ids', 0, callback, scope);
 };
 
 /**
@@ -304,7 +304,7 @@ exports.getIds = function (callback, scope) {
  * @return [ Void ]
  */
 exports.getScheduledIds = function (callback, scope) {
-    this._exec('scheduledIds', null, callback, scope);
+    this._exec('ids', 1, callback, scope);
 };
 
 /**
@@ -316,7 +316,7 @@ exports.getScheduledIds = function (callback, scope) {
  * @return [ Void ]
  */
 exports.getTriggeredIds = function (callback, scope) {
-    this._exec('triggeredIds', null, callback, scope);
+    this._exec('ids', 2, callback, scope);
 };
 
 /**
@@ -347,7 +347,7 @@ exports.get = function () {
 
     ids = this._convertIds(ids);
 
-    this._exec('notifications', ids, callback, scope);
+    this._exec('notifications', [3, ids], callback, scope);
 };
 
 /**
@@ -359,7 +359,7 @@ exports.get = function () {
  * @return [ Void ]
  */
 exports.getAll = function (callback, scope) {
-    this._exec('notifications', null, callback, scope);
+    this._exec('notifications', 0, callback, scope);
 };
 
 /**
@@ -369,7 +369,7 @@ exports.getAll = function (callback, scope) {
  * @param [ Object ]     scope    The callback function's scope.
  */
 exports.getScheduled = function (callback, scope) {
-    this._exec('scheduledNotifications', null, callback, scope);
+    this._exec('notifications', 1, callback, scope);
 };
 
 /**
@@ -379,7 +379,7 @@ exports.getScheduled = function (callback, scope) {
  * @param [ Object ]     scope    The callback function's scope.
  */
 exports.getTriggered = function (callback, scope) {
-    this._exec('triggeredNotifications', null, callback, scope);
+    this._exec('notifications', 2, callback, scope);
 };
 
 /**
@@ -394,7 +394,7 @@ exports.getTriggered = function (callback, scope) {
  */
 exports.addActions = function (id, actions, callback, scope) {
     var config = { actionGroupId: id, actions: actions };
-    this._exec('actions', [1, config], callback, scope);
+    this._exec('actions', [0, id, config], callback, scope);
 };
 
 /**
@@ -407,7 +407,7 @@ exports.addActions = function (id, actions, callback, scope) {
  * @return [ Void ]
  */
 exports.removeActions = function (id, callback, scope) {
-    this._exec('actions', [-1, id], callback, scope);
+    this._exec('actions', [1, id], callback, scope);
 };
 
 /**
@@ -420,7 +420,7 @@ exports.removeActions = function (id, callback, scope) {
  * @return [ Void ]
  */
 exports.hasActions = function (id, callback, scope) {
-    this._exec('actions', [0, id], callback, scope);
+    this._exec('actions', [2, id], callback, scope);
 };
 
 /**