Manos Chorianopoulos

fix keychain crash

......@@ -6018,7 +6018,23 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
NSDictionary *context = [JSON valueForKey:@"context"];
self.apiKey = [context valueForKey:@"api_key"];
self.webId = [context valueForKey:@"web_id"];
// [WLKeychain setString:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forKey:@"old_identifier_for_vendor"];
@try {
[WLKeychain setString:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forKey:@"old_identifier_for_vendor"];
}
@catch (NSException *exception) {
NSLog(@"WLKeychain set old_identifier_for_vendor error: %@", exception.reason);
}
@finally {
// NSLog(@"Finally condition");
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forKey:@"old_identifier_for_vendor_UD"];
[defaults setObject:[context valueForKey:@"api_key"] forKey:@"NBAPIKeyUD"];
[defaults setObject:[context valueForKey:@"web_id"] forKey:@"NBWebIDUD"];
[[NSUserDefaults standardUserDefaults] synchronize];
[_pendingOperationsQueue setSuspended:![self isRegistrationValid]];
if (success) {
......@@ -6059,11 +6075,32 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
// NSData *parameters = [NSJSONSerialization dataWithJSONObject:context options:0 error:NULL];
NSString *old_identifier_for_vendor;
@try {
if ([WLKeychain getStringForKey:@"old_identifier_for_vendor"]) {
old_identifier_for_vendor = [WLKeychain getStringForKey:@"old_identifier_for_vendor"];
} else {
old_identifier_for_vendor = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}
}
@catch (NSException *exception) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults stringForKey:@"old_identifier_for_vendor_UD"] && ![[defaults stringForKey:@"old_identifier_for_vendor_UD"] isEqual:@""]) {
old_identifier_for_vendor = [defaults stringForKey:@"old_identifier_for_vendor_UD"];
} else {
old_identifier_for_vendor = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}
}
@finally {
// NSLog(@"Finally condition");
}
// NSString *old_identifier_for_vendor;
// if ([WLKeychain getStringForKey:@"old_identifier_for_vendor"]) {
// old_identifier_for_vendor = [WLKeychain getStringForKey:@"old_identifier_for_vendor"];
// } else {
// old_identifier_for_vendor = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
// }
// NSDictionary *parameters = @{@"advertising_identifier": [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString],
// @"old_identifier_for_vendor": old_identifier_for_vendor,
......@@ -6182,9 +6219,20 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
NSDictionary *context = [JSON valueForKey:@"context"];
self.apiKey = [context valueForKey:@"api_key"];
self.webId = [context valueForKey:@"web_id"];
// [WLKeychain setString:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forKey:@"old_identifier_for_vendor"];
@try {
[WLKeychain setString:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forKey:@"old_identifier_for_vendor"];
}
@catch (NSException *exception) {
NSLog(@"WLKeychain set old_identifier_for_vendor error: %@", exception.reason);
}
@finally {
// NSLog(@"Finally condition");
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forKey:@"old_identifier_for_vendor_UD"];
[defaults setObject:[context valueForKey:@"api_key"] forKey:@"NBAPIKeyUD"];
[defaults setObject:[context valueForKey:@"web_id"] forKey:@"NBWebIDUD"];
[[NSUserDefaults standardUserDefaults] synchronize];
......@@ -6231,11 +6279,31 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
// NSData *parameters = [NSJSONSerialization dataWithJSONObject:context options:0 error:NULL];
NSString *old_identifier_for_vendor;
@try {
if ([WLKeychain getStringForKey:@"old_identifier_for_vendor"]) {
old_identifier_for_vendor = [WLKeychain getStringForKey:@"old_identifier_for_vendor"];
} else {
old_identifier_for_vendor = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}
}
@catch (NSException *exception) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults stringForKey:@"old_identifier_for_vendor_UD"] && ![[defaults stringForKey:@"old_identifier_for_vendor_UD"] isEqual:@""]) {
old_identifier_for_vendor = [defaults stringForKey:@"old_identifier_for_vendor_UD"];
} else {
old_identifier_for_vendor = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}
}
@finally {
// NSLog(@"Finally condition");
}
// if ([WLKeychain getStringForKey:@"old_identifier_for_vendor"]) {
// old_identifier_for_vendor = [WLKeychain getStringForKey:@"old_identifier_for_vendor"];
// } else {
// old_identifier_for_vendor = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
// }
// OLD parameters
// NSDictionary *parameters = @{@"advertising_identifier": [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString],
......
......@@ -93,10 +93,34 @@ static const char* jailbreak_apps[] =
_deviceToken = [aDeviceToken copy];
//Save new valuetodo
if ((_deviceToken != (NSString *)[NSNull null]) && (_deviceToken.length > 0))
if ((_deviceToken != (NSString *)[NSNull null]) && (_deviceToken.length > 0)) {
// [WLKeychain setString:_deviceToken forKey:@"NBDeviceToken"];
@try {
[WLKeychain setString:_deviceToken forKey:@"NBDeviceToken"];
else
}
@catch (NSException *exception) {
NSLog(@"WLKeychain set DeviceToken error: %@", exception.reason);
}
@finally {
// NSLog(@"Finally condition");
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:_deviceToken forKey:@"NBDeviceTokenUD"];
} else {
// [WLKeychain deleteStringForKey:@"NBDeviceToken"];
@try {
[WLKeychain deleteStringForKey:@"NBDeviceToken"];
}
@catch (NSException *exception) {
NSLog(@"WLKeychain delete DeviceToken error: %@", exception.reason);
}
@finally {
// NSLog(@"Finally condition");
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"" forKey:@"NBDeviceTokenUD"];
}
}
#pragma mark - Public Methods
......