Forráskód Böngészése

Exec `cancel` in background

Sebastián Katzer 12 éve
szülő
commit
60b501aba2
1 módosított fájl, 12 hozzáadás és 10 törlés
  1. 12 10
      src/ios/APPLocalNotification.m

+ 12 - 10
src/ios/APPLocalNotification.m

@@ -59,19 +59,21 @@
  */
 - (void) cancel:(CDVInvokedUrlCommand*)command
 {
-    NSArray* arguments       = [command arguments];
-    NSString* notificationId = [arguments objectAtIndex:0];
-    NSArray* notifications   = [[UIApplication sharedApplication] scheduledLocalNotifications];
-
-    for (UILocalNotification *notification in notifications)
-    {
-        NSString *id = [notification.userInfo objectForKey:@"id"];
+    [self.commandDelegate runInBackground:^{
+        NSArray* arguments       = [command arguments];
+        NSString* notificationId = [arguments objectAtIndex:0];
+        NSArray* notifications   = [[UIApplication sharedApplication] scheduledLocalNotifications];
 
-        if ([notificationId isEqualToString:id])
+        for (UILocalNotification* notification in notifications)
         {
-            [[UIApplication sharedApplication] cancelLocalNotification:notification];
+            NSString* id = [notification.userInfo objectForKey:@"id"];
+
+            if ([notificationId isEqualToString:id])
+            {
+                [[UIApplication sharedApplication] cancelLocalNotification:notification];
+            }
         }
-    }
+    }];
 }
 
 /**