Loading src/ios/PushPlugin.m +8 −65 Changes for src/ios/PushPlugin.m: 8 added lines, 65 removed lines. Original line number Diff line number Diff line Loading @@ -49,58 +49,35 @@ self.callbackId = command.callbackId; NSMutableDictionary* options = [command.arguments objectAtIndex:0]; NSMutableDictionary* iosOptions = [options objectForKey:@"ios"]; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UIUserNotificationType UserNotificationTypes = UIUserNotificationTypeNone; #endif UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeNone; id badgeArg = [options objectForKey:@"badge"]; id soundArg = [options objectForKey:@"sound"]; id alertArg = [options objectForKey:@"alert"]; id badgeArg = [iosOptions objectForKey:@"badge"]; id soundArg = [iosOptions objectForKey:@"sound"]; id alertArg = [iosOptions objectForKey:@"alert"]; if ([badgeArg isKindOfClass:[NSString class]]) if (([badgeArg isKindOfClass:[NSString class]] && [badgeArg isEqualToString:@"true"]) || [badgeArg boolValue]) { if ([badgeArg isEqualToString:@"true"]) { notificationTypes |= UIRemoteNotificationTypeBadge; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UserNotificationTypes |= UIUserNotificationTypeBadge; #endif } } else if ([badgeArg boolValue]) { notificationTypes |= UIRemoteNotificationTypeBadge; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UserNotificationTypes |= UIUserNotificationTypeBadge; #endif } if ([soundArg isKindOfClass:[NSString class]]) if (([soundArg isKindOfClass:[NSString class]] && [soundArg isEqualToString:@"true"]) || [soundArg boolValue]) { if ([soundArg isEqualToString:@"true"]) { notificationTypes |= UIRemoteNotificationTypeSound; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UserNotificationTypes |= UIUserNotificationTypeSound; #endif } } else if ([soundArg boolValue]) { notificationTypes |= UIRemoteNotificationTypeSound; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UserNotificationTypes |= UIUserNotificationTypeSound; #endif } if ([alertArg isKindOfClass:[NSString class]]) if (([alertArg isKindOfClass:[NSString class]] && [alertArg isEqualToString:@"true"]) || [alertArg boolValue]) { if ([alertArg isEqualToString:@"true"]) { notificationTypes |= UIRemoteNotificationTypeAlert; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UserNotificationTypes |= UIUserNotificationTypeAlert; #endif } } else if ([alertArg boolValue]) { notificationTypes |= UIRemoteNotificationTypeAlert; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UserNotificationTypes |= UIUserNotificationTypeAlert; Loading @@ -112,8 +89,6 @@ UserNotificationTypes |= UIUserNotificationActivationModeBackground; #endif self.callback = [options objectForKey:@"ecb"]; if (notificationTypes == UIRemoteNotificationTypeNone) NSLog(@"PushPlugin.register: Push notification type is set to none"); Loading @@ -135,14 +110,6 @@ [self notificationReceived]; // go ahead and process it } /* - (void)isEnabled:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options { UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; NSString *jsStatement = [NSString stringWithFormat:@"navigator.PushPlugin.isEnabled = %d;", type != UIRemoteNotificationTypeNone]; NSLog(@"JSStatement %@",jsStatement); } */ - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSLog(@"Push Plugin register success: %@", deviceToken); Loading Loading @@ -255,31 +222,6 @@ } } // reentrant method to drill down and surface all sub-dictionaries' key/value pairs into the top level json -(void)parseDictionary:(NSDictionary *)inDictionary intoJSON:(NSMutableString *)jsonString { NSArray *keys = [inDictionary allKeys]; NSString *key; for (key in keys) { id thisObject = [inDictionary objectForKey:key]; if ([thisObject isKindOfClass:[NSDictionary class]]) [self parseDictionary:thisObject intoJSON:jsonString]; else if ([thisObject isKindOfClass:[NSString class]]) [jsonString appendFormat:@"\"%@\":\"%@\",", key, [[[[inDictionary objectForKey:key] stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"] stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""] stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"]]; else { [jsonString appendFormat:@"\"%@\":\"%@\",", key, [inDictionary objectForKey:key]]; } } } - (void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command { self.callbackId = command.callbackId; Loading @@ -291,6 +233,7 @@ [self successWithMessage:[NSString stringWithFormat:@"app badge count set to %d", badge]]; } -(void)successWithMessage:(NSString *)message { if (self.callbackId != nil) Loading Loading
src/ios/PushPlugin.m +8 −65 Changes for src/ios/PushPlugin.m: 8 added lines, 65 removed lines. Original line number Diff line number Diff line Loading @@ -49,58 +49,35 @@ self.callbackId = command.callbackId; NSMutableDictionary* options = [command.arguments objectAtIndex:0]; NSMutableDictionary* iosOptions = [options objectForKey:@"ios"]; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UIUserNotificationType UserNotificationTypes = UIUserNotificationTypeNone; #endif UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeNone; id badgeArg = [options objectForKey:@"badge"]; id soundArg = [options objectForKey:@"sound"]; id alertArg = [options objectForKey:@"alert"]; id badgeArg = [iosOptions objectForKey:@"badge"]; id soundArg = [iosOptions objectForKey:@"sound"]; id alertArg = [iosOptions objectForKey:@"alert"]; if ([badgeArg isKindOfClass:[NSString class]]) if (([badgeArg isKindOfClass:[NSString class]] && [badgeArg isEqualToString:@"true"]) || [badgeArg boolValue]) { if ([badgeArg isEqualToString:@"true"]) { notificationTypes |= UIRemoteNotificationTypeBadge; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UserNotificationTypes |= UIUserNotificationTypeBadge; #endif } } else if ([badgeArg boolValue]) { notificationTypes |= UIRemoteNotificationTypeBadge; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UserNotificationTypes |= UIUserNotificationTypeBadge; #endif } if ([soundArg isKindOfClass:[NSString class]]) if (([soundArg isKindOfClass:[NSString class]] && [soundArg isEqualToString:@"true"]) || [soundArg boolValue]) { if ([soundArg isEqualToString:@"true"]) { notificationTypes |= UIRemoteNotificationTypeSound; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UserNotificationTypes |= UIUserNotificationTypeSound; #endif } } else if ([soundArg boolValue]) { notificationTypes |= UIRemoteNotificationTypeSound; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UserNotificationTypes |= UIUserNotificationTypeSound; #endif } if ([alertArg isKindOfClass:[NSString class]]) if (([alertArg isKindOfClass:[NSString class]] && [alertArg isEqualToString:@"true"]) || [alertArg boolValue]) { if ([alertArg isEqualToString:@"true"]) { notificationTypes |= UIRemoteNotificationTypeAlert; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UserNotificationTypes |= UIUserNotificationTypeAlert; #endif } } else if ([alertArg boolValue]) { notificationTypes |= UIRemoteNotificationTypeAlert; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UserNotificationTypes |= UIUserNotificationTypeAlert; Loading @@ -112,8 +89,6 @@ UserNotificationTypes |= UIUserNotificationActivationModeBackground; #endif self.callback = [options objectForKey:@"ecb"]; if (notificationTypes == UIRemoteNotificationTypeNone) NSLog(@"PushPlugin.register: Push notification type is set to none"); Loading @@ -135,14 +110,6 @@ [self notificationReceived]; // go ahead and process it } /* - (void)isEnabled:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options { UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; NSString *jsStatement = [NSString stringWithFormat:@"navigator.PushPlugin.isEnabled = %d;", type != UIRemoteNotificationTypeNone]; NSLog(@"JSStatement %@",jsStatement); } */ - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSLog(@"Push Plugin register success: %@", deviceToken); Loading Loading @@ -255,31 +222,6 @@ } } // reentrant method to drill down and surface all sub-dictionaries' key/value pairs into the top level json -(void)parseDictionary:(NSDictionary *)inDictionary intoJSON:(NSMutableString *)jsonString { NSArray *keys = [inDictionary allKeys]; NSString *key; for (key in keys) { id thisObject = [inDictionary objectForKey:key]; if ([thisObject isKindOfClass:[NSDictionary class]]) [self parseDictionary:thisObject intoJSON:jsonString]; else if ([thisObject isKindOfClass:[NSString class]]) [jsonString appendFormat:@"\"%@\":\"%@\",", key, [[[[inDictionary objectForKey:key] stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"] stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""] stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"]]; else { [jsonString appendFormat:@"\"%@\":\"%@\",", key, [inDictionary objectForKey:key]]; } } } - (void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command { self.callbackId = command.callbackId; Loading @@ -291,6 +233,7 @@ [self successWithMessage:[NSString stringWithFormat:@"app badge count set to %d", badge]]; } -(void)successWithMessage:(NSString *)message { if (self.callbackId != nil) Loading