Loading src/ios/APPLocalNotification.h +2 −0 Changes for src/ios/APPLocalNotification.h: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ - (void) deviceready:(CDVInvokedUrlCommand*)command; // Schedule a new notification - (void) add:(CDVInvokedUrlCommand*)command; // Update a notification - (void) update:(CDVInvokedUrlCommand*)command; // Cancel a given notification - (void) cancel:(CDVInvokedUrlCommand*)command; // Cancel all currently scheduled notifications Loading src/ios/APPLocalNotification.m +58 −7 Changes for src/ios/APPLocalNotification.m: 58 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ NSArray* notifications = command.arguments; [self.commandDelegate runInBackground:^{ for (NSMutableDictionary* options in notifications) { for (NSDictionary* options in notifications) { UILocalNotification* notification; notification = [[UILocalNotification alloc] Loading @@ -90,6 +90,39 @@ }]; } /** * Update a set of notifications. * * @param properties * A dict of properties for each notification */ - (void) update:(CDVInvokedUrlCommand*)command { NSArray* notifications = command.arguments; [self.commandDelegate runInBackground:^{ for (NSDictionary* options in notifications) { NSString* id = [options objectForKey:@"id"]; UILocalNotification* notification; notification = [[UIApplication sharedApplication] scheduledLocalNotificationWithId:id]; if (!notification) continue; [self updateLocalNotification:[notification copy] withOptions:options]; if (notifications.count > 1) { [NSThread sleepForTimeInterval:0.01]; } } [self execCallback:command]; }]; } /** * Cancel a set of notifications. * Loading Loading @@ -335,14 +368,29 @@ scheduleLocalNotification:notification]; } /** * Update the local notification. */ - (void) updateLocalNotification:(UILocalNotification*)notification withOptions:(NSDictionary*)newOptions { NSMutableDictionary* options = [notification.userInfo mutableCopy]; [options addEntriesFromDictionary:newOptions]; [options setObject:[NSDate date] forKey:@"updatedAt"]; notification = [[UILocalNotification alloc] initWithOptions:options]; [self scheduleLocalNotification:notification]; } /** * Cancel the local notification. */ - (void) cancelLocalNotification:(UILocalNotification*)notification { if (!notification) return; [[UIApplication sharedApplication] cancelLocalNotification:notification]; Loading Loading @@ -392,7 +440,7 @@ for (UILocalNotification* notification in notifications) { if (notification && notification.repeatInterval == NSCalendarUnitEra if (notification && [notification isRepeating] && notification.timeIntervalSinceFireDate > seconds) { [self cancelLocalNotification:notification]; Loading @@ -412,8 +460,11 @@ { UILocalNotification* notification = [localNotification object]; if ([notification wasUpdated]) return; BOOL autoCancel = notification.options.autoCancel; NSTimeInterval timeInterval = notification.timeIntervalSinceFireDate; NSTimeInterval timeInterval = [notification timeIntervalSinceFireDate]; NSString* event = (timeInterval <= 1 && deviceready) ? @"trigger" : @"click"; Loading Loading @@ -551,7 +602,7 @@ if (notification) { NSString* id = notification.options.id; NSString* json = notification.options.json; NSString* args = [notification.options encodeToJSON]; NSString* args = [notification encodeToJSON]; params = [NSString stringWithFormat: @"\"%@\",\"%@\",\\'%@\\',JSON.parse(\\'%@\\')", Loading src/ios/APPLocalNotificationOptions.h +0 −2 Changes for src/ios/APPLocalNotificationOptions.h: 0 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -33,8 +33,6 @@ @property (readonly, getter=repeatInterval) NSCalendarUnit repeatInterval; @property (readonly, getter=userInfo) NSDictionary* userInfo; // Encode the user info dict to JSON - (NSString*) encodeToJSON; // If it's a repeating notification - (BOOL) isRepeating; Loading src/ios/APPLocalNotificationOptions.m +0 −22 Changes for src/ios/APPLocalNotificationOptions.m: 0 added lines, 22 removed lines. Original line number Diff line number Diff line Loading @@ -212,28 +212,6 @@ return dict; } /** * Encode the user info dict to JSON. */ - (NSString*) encodeToJSON { NSString* json; NSData* data; NSMutableDictionary* obj = [dict mutableCopy]; [obj removeObjectForKey:@"json"]; data = [NSJSONSerialization dataWithJSONObject:obj options:NSJSONWritingPrettyPrinted error:Nil]; json = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; return [json stringByReplacingOccurrencesOfString:@"\n" withString:@""]; } /** * If it's a repeating notification. */ Loading src/ios/UILocalNotification+APPLocalNotification.h +4 −0 Changes for src/ios/UILocalNotification+APPLocalNotification.h: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -33,7 +33,11 @@ - (BOOL) wasInThePast; // If the notification was already triggered - (BOOL) wasTriggered; // If the notification was updated - (BOOL) wasUpdated; // If it's a repeating notification - (BOOL) isRepeating; // Encode the user info dict to JSON - (NSString*) encodeToJSON; @end Loading
src/ios/APPLocalNotification.h +2 −0 Changes for src/ios/APPLocalNotification.h: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ - (void) deviceready:(CDVInvokedUrlCommand*)command; // Schedule a new notification - (void) add:(CDVInvokedUrlCommand*)command; // Update a notification - (void) update:(CDVInvokedUrlCommand*)command; // Cancel a given notification - (void) cancel:(CDVInvokedUrlCommand*)command; // Cancel all currently scheduled notifications Loading
src/ios/APPLocalNotification.m +58 −7 Changes for src/ios/APPLocalNotification.m: 58 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ NSArray* notifications = command.arguments; [self.commandDelegate runInBackground:^{ for (NSMutableDictionary* options in notifications) { for (NSDictionary* options in notifications) { UILocalNotification* notification; notification = [[UILocalNotification alloc] Loading @@ -90,6 +90,39 @@ }]; } /** * Update a set of notifications. * * @param properties * A dict of properties for each notification */ - (void) update:(CDVInvokedUrlCommand*)command { NSArray* notifications = command.arguments; [self.commandDelegate runInBackground:^{ for (NSDictionary* options in notifications) { NSString* id = [options objectForKey:@"id"]; UILocalNotification* notification; notification = [[UIApplication sharedApplication] scheduledLocalNotificationWithId:id]; if (!notification) continue; [self updateLocalNotification:[notification copy] withOptions:options]; if (notifications.count > 1) { [NSThread sleepForTimeInterval:0.01]; } } [self execCallback:command]; }]; } /** * Cancel a set of notifications. * Loading Loading @@ -335,14 +368,29 @@ scheduleLocalNotification:notification]; } /** * Update the local notification. */ - (void) updateLocalNotification:(UILocalNotification*)notification withOptions:(NSDictionary*)newOptions { NSMutableDictionary* options = [notification.userInfo mutableCopy]; [options addEntriesFromDictionary:newOptions]; [options setObject:[NSDate date] forKey:@"updatedAt"]; notification = [[UILocalNotification alloc] initWithOptions:options]; [self scheduleLocalNotification:notification]; } /** * Cancel the local notification. */ - (void) cancelLocalNotification:(UILocalNotification*)notification { if (!notification) return; [[UIApplication sharedApplication] cancelLocalNotification:notification]; Loading Loading @@ -392,7 +440,7 @@ for (UILocalNotification* notification in notifications) { if (notification && notification.repeatInterval == NSCalendarUnitEra if (notification && [notification isRepeating] && notification.timeIntervalSinceFireDate > seconds) { [self cancelLocalNotification:notification]; Loading @@ -412,8 +460,11 @@ { UILocalNotification* notification = [localNotification object]; if ([notification wasUpdated]) return; BOOL autoCancel = notification.options.autoCancel; NSTimeInterval timeInterval = notification.timeIntervalSinceFireDate; NSTimeInterval timeInterval = [notification timeIntervalSinceFireDate]; NSString* event = (timeInterval <= 1 && deviceready) ? @"trigger" : @"click"; Loading Loading @@ -551,7 +602,7 @@ if (notification) { NSString* id = notification.options.id; NSString* json = notification.options.json; NSString* args = [notification.options encodeToJSON]; NSString* args = [notification encodeToJSON]; params = [NSString stringWithFormat: @"\"%@\",\"%@\",\\'%@\\',JSON.parse(\\'%@\\')", Loading
src/ios/APPLocalNotificationOptions.h +0 −2 Changes for src/ios/APPLocalNotificationOptions.h: 0 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -33,8 +33,6 @@ @property (readonly, getter=repeatInterval) NSCalendarUnit repeatInterval; @property (readonly, getter=userInfo) NSDictionary* userInfo; // Encode the user info dict to JSON - (NSString*) encodeToJSON; // If it's a repeating notification - (BOOL) isRepeating; Loading
src/ios/APPLocalNotificationOptions.m +0 −22 Changes for src/ios/APPLocalNotificationOptions.m: 0 added lines, 22 removed lines. Original line number Diff line number Diff line Loading @@ -212,28 +212,6 @@ return dict; } /** * Encode the user info dict to JSON. */ - (NSString*) encodeToJSON { NSString* json; NSData* data; NSMutableDictionary* obj = [dict mutableCopy]; [obj removeObjectForKey:@"json"]; data = [NSJSONSerialization dataWithJSONObject:obj options:NSJSONWritingPrettyPrinted error:Nil]; json = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; return [json stringByReplacingOccurrencesOfString:@"\n" withString:@""]; } /** * If it's a repeating notification. */ Loading
src/ios/UILocalNotification+APPLocalNotification.h +4 −0 Changes for src/ios/UILocalNotification+APPLocalNotification.h: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -33,7 +33,11 @@ - (BOOL) wasInThePast; // If the notification was already triggered - (BOOL) wasTriggered; // If the notification was updated - (BOOL) wasUpdated; // If it's a repeating notification - (BOOL) isRepeating; // Encode the user info dict to JSON - (NSString*) encodeToJSON; @end