Loading README.md +1 −0 Changes for README.md: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ More informations can be found [here](https://build.phonegap.com/plugins/413). #### Version 0.7.3 (not yet released) - [bugfix:] cancel callbacks have not been fired after all notifications have been canceled on iOS. - [change:] The `oncancel` callback will be called at last if `autoCancel` is set to true (iOS). - [bugfix:] Callbacks for non-repeating notifications were not called if they were not created in the current app instance on iOS. #### Version 0.7.2 (09.02.2014) - [enhancement:] Avoid blocking the main thread (on Android) **(dpogue)**. Loading src/ios/APPLocalNotification.m +40 −1 Changes for src/ios/APPLocalNotification.m: 40 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -140,6 +140,37 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION"; } } /** * Entfernt alle Meldungen, die älter als x Sekunden sind. * * @param {float} seconds */ - (void) cancelAllNotificationsWhichAreOlderThen:(float)seconds { NSDictionary* entries = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]; NSDate* now = [NSDate date]; for (NSString* key in [entries allKeys]) { if ([key hasPrefix:kAPP_LOCALNOTIFICATION]) { NSData* data = [[NSUserDefaults standardUserDefaults] objectForKey:key]; if (data) { UILocalNotification* notification = [NSKeyedUnarchiver unarchiveObjectWithData:data]; NSTimeInterval fireDateDistance = [now timeIntervalSinceDate:notification.fireDate]; NSString* id = [notification.userInfo objectForKey:@"id"]; if (notification.repeatInterval == NSEraCalendarUnit && fireDateDistance > seconds) { [self cancelNotificationWithId:id fireEvent:YES]; } } } } } /** * Archiviert die Meldungen, sodass sie später abgerufen werden kann. * Loading Loading @@ -179,7 +210,7 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION"; [repeatDict setObject:[NSNumber numberWithInt:NSYearCalendarUnit] forKey:@"yearly"]; #endif [repeatDict setObject:[NSNumber numberWithInt:0] forKey:@""]; [repeatDict setObject:[NSNumber numberWithInt:NSEraCalendarUnit] forKey:@""]; return repeatDict; } Loading Loading @@ -277,6 +308,14 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION"; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveLocalNotification:) name:CDVLocalNotification object:nil]; } /** * Löscht alle single-repeat Notifications, die älter als 5 Tage sind. */ - (void) onAppTerminate { [self cancelAllNotificationsWhichAreOlderThen:10]; } /** * Hilfsmethode gibt an, ob er String NULL oder Empty ist. */ Loading Loading
README.md +1 −0 Changes for README.md: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ More informations can be found [here](https://build.phonegap.com/plugins/413). #### Version 0.7.3 (not yet released) - [bugfix:] cancel callbacks have not been fired after all notifications have been canceled on iOS. - [change:] The `oncancel` callback will be called at last if `autoCancel` is set to true (iOS). - [bugfix:] Callbacks for non-repeating notifications were not called if they were not created in the current app instance on iOS. #### Version 0.7.2 (09.02.2014) - [enhancement:] Avoid blocking the main thread (on Android) **(dpogue)**. Loading
src/ios/APPLocalNotification.m +40 −1 Changes for src/ios/APPLocalNotification.m: 40 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -140,6 +140,37 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION"; } } /** * Entfernt alle Meldungen, die älter als x Sekunden sind. * * @param {float} seconds */ - (void) cancelAllNotificationsWhichAreOlderThen:(float)seconds { NSDictionary* entries = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]; NSDate* now = [NSDate date]; for (NSString* key in [entries allKeys]) { if ([key hasPrefix:kAPP_LOCALNOTIFICATION]) { NSData* data = [[NSUserDefaults standardUserDefaults] objectForKey:key]; if (data) { UILocalNotification* notification = [NSKeyedUnarchiver unarchiveObjectWithData:data]; NSTimeInterval fireDateDistance = [now timeIntervalSinceDate:notification.fireDate]; NSString* id = [notification.userInfo objectForKey:@"id"]; if (notification.repeatInterval == NSEraCalendarUnit && fireDateDistance > seconds) { [self cancelNotificationWithId:id fireEvent:YES]; } } } } } /** * Archiviert die Meldungen, sodass sie später abgerufen werden kann. * Loading Loading @@ -179,7 +210,7 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION"; [repeatDict setObject:[NSNumber numberWithInt:NSYearCalendarUnit] forKey:@"yearly"]; #endif [repeatDict setObject:[NSNumber numberWithInt:0] forKey:@""]; [repeatDict setObject:[NSNumber numberWithInt:NSEraCalendarUnit] forKey:@""]; return repeatDict; } Loading Loading @@ -277,6 +308,14 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION"; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveLocalNotification:) name:CDVLocalNotification object:nil]; } /** * Löscht alle single-repeat Notifications, die älter als 5 Tage sind. */ - (void) onAppTerminate { [self cancelAllNotificationsWhichAreOlderThen:10]; } /** * Hilfsmethode gibt an, ob er String NULL oder Empty ist. */ Loading