Jelajahi Sumber

Adding notifications on iOS does not block the ui thread anymore.

Sebastián Katzer 12 tahun lalu
induk
melakukan
59f204d66a
2 mengubah file dengan 8 tambahan dan 5 penghapusan
  1. 1 0
      README.md
  2. 7 5
      src/ios/APPLocalNotification.m

+ 1 - 0
README.md

@@ -39,6 +39,7 @@ cordova plugin rm de.appplant.cordova.plugin.local-notifications
 - [feature:] Sound can be specified under Android.
 - [enhancement:] Adding notifications on Android does not block the ui thread anymore.
 - [bugfix:] The app did stop/crash after removing them from recent apps list.
+- [enhancement:] Adding notifications on iOS does not block the ui thread anymore.
 
 #### Version 0.6.0 (16.11.2013)
 - Added WP8 support<br>

+ 7 - 5
src/ios/APPLocalNotification.m

@@ -29,13 +29,15 @@
  */
 - (void) add:(CDVInvokedUrlCommand*)command
 {
-    NSArray             *arguments    = [command arguments];
-    NSMutableDictionary *options      = [arguments objectAtIndex:0];
-    UILocalNotification *notification = [self prepareNotification:options];
+    [self.commandDelegate runInBackground:^{
+        NSArray             *arguments    = [command arguments];
+        NSMutableDictionary *options      = [arguments objectAtIndex:0];
+        UILocalNotification *notification = [self prepareNotification:options];
 
-    notification.userInfo = [self userDict:options];
+        notification.userInfo = [self userDict:options];
 
-    [[UIApplication sharedApplication] scheduleLocalNotification:notification];
+        [[UIApplication sharedApplication] scheduleLocalNotification:notification];
+    }];
 }
 
 /**