Sfoglia il codice sorgente

Fix get* with single id on iOS

Sebastián Katzer 10 anni fa
parent
commit
388adbd4b5
2 ha cambiato i file con 61 aggiunte e 0 eliminazioni
  1. 7 0
      src/ios/APPLocalNotification.h
  2. 54 0
      src/ios/APPLocalNotification.m

+ 7 - 0
src/ios/APPLocalNotification.h

@@ -61,6 +61,13 @@
 // List all ids from all triggered notifications
 - (void) getTriggeredIds:(CDVInvokedUrlCommand*)command;
 
+// Propertys for given local notification
+- (void) getSingle:(CDVInvokedUrlCommand*)command;
+// Propertya for given scheduled notification
+- (void) getSingleScheduled:(CDVInvokedUrlCommand*)command;
+// Propertys for given triggered notification
+- (void) getSingleTriggered:(CDVInvokedUrlCommand*)command;
+
 // Property list for given local notifications
 - (void) getAll:(CDVInvokedUrlCommand*)command;
 // Property list for given scheduled notifications

+ 54 - 0
src/ios/APPLocalNotification.m

@@ -313,6 +313,28 @@
     }];
 }
 
+/**
+ * Propertys for given local notification.
+ */
+- (void) getSingle:(CDVInvokedUrlCommand*)command
+{
+    [self getOption:command byType:NotifcationTypeAll];
+}
+
+/**
+ * Propertya for given scheduled notification.
+ */
+- (void) getSingleScheduled:(CDVInvokedUrlCommand*)command
+{
+    [self getOption:command byType:NotifcationTypeScheduled];
+}
+
+// Propertys for given triggered notification
+- (void) getSingleTriggered:(CDVInvokedUrlCommand*)command
+{
+    [self getOption:command byType:NotifcationTypeTriggered];
+}
+
 /**
  * Property list for given local notifications.
  *
@@ -346,6 +368,38 @@
     [self getOptions:command byType:NotifcationTypeTriggered];
 }
 
+/**
+ * Propertys for given triggered notification.
+ *
+ * @param type
+ *      Notification life cycle type
+ * @param ids
+ *      The ID of the notification
+ */
+- (void) getOption:(CDVInvokedUrlCommand*)command
+            byType:(APPLocalNotificationType)type;
+{
+    [self.commandDelegate runInBackground:^{
+        NSArray* ids = command.arguments;
+        NSArray* notifications;
+        CDVPluginResult* result;
+
+        if (type == NotifcationTypeAll) {
+            notifications = [self.app localNotificationOptionsById:ids];
+        }
+        else {
+            notifications = [self.app localNotificationOptionsByType:type
+                                                               andId:ids];
+        }
+
+        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
+                                    messageAsDictionary:notifications[0]];
+
+        [self.commandDelegate sendPluginResult:result
+                                    callbackId:command.callbackId];
+    }];
+}
+
 /**
  * Property list for given triggered notifications.
  *