From 1132c9be0ca1e5e5833d65530746d199e2db329c Mon Sep 17 00:00:00 2001 From: Daniel Molin Date: Thu, 1 Nov 2018 10:54:26 +0100 Subject: [PATCH 1/2] fix(ios): Add support for reading __NSCFData key strings --- src/ios/SecureStorage.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ios/SecureStorage.m b/src/ios/SecureStorage.m index 68edbb40..613081ef 100644 --- a/src/ios/SecureStorage.m +++ b/src/ios/SecureStorage.m @@ -114,7 +114,11 @@ - (void)keys:(CDVInvokedUrlCommand*)command if (accounts) { NSMutableArray *array = [NSMutableArray arrayWithCapacity:[accounts count]]; for (id dict in accounts) { - [array addObject:[dict valueForKeyPath:@"acct"]]; + if([NSStringFromClass([[dict valueForKeyPath:@"acct"] class]) isEqualToString:@"__NSCFData"]){ + [array addObject:[NSString stringWithUTF8String:[[dict valueForKeyPath:@"acct"] bytes]]]; + }else{ + [array addObject:[dict valueForKeyPath:@"acct"]]; + } } CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:array]; From a5aec347ba19e747b35b6c95c9b7a8816efb002e Mon Sep 17 00:00:00 2001 From: Daniel Molin Date: Mon, 12 Nov 2018 13:48:14 +0100 Subject: [PATCH 2/2] fix(ios): Wrap string conversion in try/catch --- src/ios/SecureStorage.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ios/SecureStorage.m b/src/ios/SecureStorage.m index 613081ef..b8a9b32a 100644 --- a/src/ios/SecureStorage.m +++ b/src/ios/SecureStorage.m @@ -115,7 +115,11 @@ - (void)keys:(CDVInvokedUrlCommand*)command NSMutableArray *array = [NSMutableArray arrayWithCapacity:[accounts count]]; for (id dict in accounts) { if([NSStringFromClass([[dict valueForKeyPath:@"acct"] class]) isEqualToString:@"__NSCFData"]){ - [array addObject:[NSString stringWithUTF8String:[[dict valueForKeyPath:@"acct"] bytes]]]; + @try { + [array addObject:[NSString stringWithUTF8String:[[dict valueForKeyPath:@"acct"] bytes]]]; + } @catch (NSException *exception) { + // Just ignore this key :( + } }else{ [array addObject:[dict valueForKeyPath:@"acct"]]; }