Loading src/ios/APPLocalNotification.m +38 −6 Changes for src/ios/APPLocalNotification.m: 38 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ - (NSDictionary*) userDict:(NSMutableDictionary*)options; - (UILocalNotification*) prepareNotification:(NSMutableDictionary*)options; - (void)aWindowBecameMain:(NSNotification *)notification; @end Loading Loading @@ -48,10 +50,12 @@ NSString *notificationId = [arguments objectAtIndex:0]; NSArray *notifications = [[UIApplication sharedApplication] scheduledLocalNotifications]; for (UILocalNotification *notification in notifications) { for (UILocalNotification *notification in notifications) { NSString *notId = [notification.userInfo objectForKey:@"notificationId"]; if ([notificationId isEqualToString:notId]) { if ([notificationId isEqualToString:notId]) { [[UIApplication sharedApplication] cancelLocalNotification:notification]; } } Loading Loading @@ -86,13 +90,11 @@ */ - (NSDictionary*) userDict:(NSMutableDictionary*)options { NSString *notificationId = [options objectForKey:@"id"]; NSString* id = [options objectForKey:@"id"]; NSString* bg = [options objectForKey:@"background"]; NSString* fg = [options objectForKey:@"foreground"]; NSDictionary *userDict = [NSDictionary dictionaryWithObjectsAndKeys:notificationId, @"notificationId", bg, @"background", fg, @"foreground", nil]; return userDict; return [NSDictionary dictionaryWithObjectsAndKeys:id, @"id", bg, @"background", fg, @"foreground", nil]; } /** Loading Loading @@ -123,4 +125,34 @@ return notification; } /** * @private * Ruft die JS-Callbacks auf, nachdem eine Notification eingegangen ist. */ - (void) didReceiveLocalNotification:(NSNotification *)localNotification { UILocalNotification* notification = [localNotification object]; UIApplicationState state = [[UIApplication sharedApplication] applicationState]; bool isActive = state == UIApplicationStateActive; NSString* id = [notification.userInfo objectForKey:@"id"]; NSString* callbackFn = [notification.userInfo objectForKey:isActive ? @"foreground" : @"background"]; if (callbackFn.length > 0) { NSString* jsCallBack = [NSString stringWithFormat:@"%@(%@)", callbackFn, id]; [self writeJavascript:jsCallBack]; } } /** * @private * Registriert den Observer für LocalNotification Events. */ - (void) pluginInitialize { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveLocalNotification:) name:CDVLocalNotification object:nil]; } @end No newline at end of file Loading
src/ios/APPLocalNotification.m +38 −6 Changes for src/ios/APPLocalNotification.m: 38 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ - (NSDictionary*) userDict:(NSMutableDictionary*)options; - (UILocalNotification*) prepareNotification:(NSMutableDictionary*)options; - (void)aWindowBecameMain:(NSNotification *)notification; @end Loading Loading @@ -48,10 +50,12 @@ NSString *notificationId = [arguments objectAtIndex:0]; NSArray *notifications = [[UIApplication sharedApplication] scheduledLocalNotifications]; for (UILocalNotification *notification in notifications) { for (UILocalNotification *notification in notifications) { NSString *notId = [notification.userInfo objectForKey:@"notificationId"]; if ([notificationId isEqualToString:notId]) { if ([notificationId isEqualToString:notId]) { [[UIApplication sharedApplication] cancelLocalNotification:notification]; } } Loading Loading @@ -86,13 +90,11 @@ */ - (NSDictionary*) userDict:(NSMutableDictionary*)options { NSString *notificationId = [options objectForKey:@"id"]; NSString* id = [options objectForKey:@"id"]; NSString* bg = [options objectForKey:@"background"]; NSString* fg = [options objectForKey:@"foreground"]; NSDictionary *userDict = [NSDictionary dictionaryWithObjectsAndKeys:notificationId, @"notificationId", bg, @"background", fg, @"foreground", nil]; return userDict; return [NSDictionary dictionaryWithObjectsAndKeys:id, @"id", bg, @"background", fg, @"foreground", nil]; } /** Loading Loading @@ -123,4 +125,34 @@ return notification; } /** * @private * Ruft die JS-Callbacks auf, nachdem eine Notification eingegangen ist. */ - (void) didReceiveLocalNotification:(NSNotification *)localNotification { UILocalNotification* notification = [localNotification object]; UIApplicationState state = [[UIApplication sharedApplication] applicationState]; bool isActive = state == UIApplicationStateActive; NSString* id = [notification.userInfo objectForKey:@"id"]; NSString* callbackFn = [notification.userInfo objectForKey:isActive ? @"foreground" : @"background"]; if (callbackFn.length > 0) { NSString* jsCallBack = [NSString stringWithFormat:@"%@(%@)", callbackFn, id]; [self writeJavascript:jsCallBack]; } } /** * @private * Registriert den Observer für LocalNotification Events. */ - (void) pluginInitialize { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveLocalNotification:) name:CDVLocalNotification object:nil]; } @end No newline at end of file