Manos Chorianopoulos

possible fix for initialize crash

...@@ -241,12 +241,29 @@ typedef void (^FailureResponse)(NSURLSessionDataTask * _Nullable task, NSError * ...@@ -241,12 +241,29 @@ typedef void (^FailureResponse)(NSURLSessionDataTask * _Nullable task, NSError *
241 241
242 [self createDBIfNeeded]; 242 [self createDBIfNeeded];
243 [self initDBIfNeeded]; 243 [self initDBIfNeeded];
244 + // [self restore];
245 +
246 + @try {
244 [self restore]; 247 [self restore];
248 + }
249 + @catch (NSException *exception) {
250 + NSLog(@"restore error: %@", exception.reason);
251 +
252 + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
253 + self.appUUID = [defaults stringForKey:@"NBAPPUuidUD"];
254 + self.apiKey = [defaults stringForKey:@"NBAPIKeyUD"];
255 + self.webId = [defaults stringForKey:@"NBWebIDUD"];
256 + }
257 + @finally {
258 +// NSLog(@"Finally condition");
259 + }
260 +
245 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 261 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
246 if ([_appUUID isEqualToString:appUUID] == NO) { 262 if ([_appUUID isEqualToString:appUUID] == NO) {
247 self.appUUID = appUUID; 263 self.appUUID = appUUID;
248 self.apiKey = nil; 264 self.apiKey = nil;
249 self.webId = nil; 265 self.webId = nil;
266 + [defaults setObject:appUUID forKey:@"NBAPPUuidUD"];
250 [defaults setBool:YES forKey:@"NBAPPUuidChanged"]; 267 [defaults setBool:YES forKey:@"NBAPPUuidChanged"];
251 } 268 }
252 else [defaults setBool:NO forKey:@"NBAPPUuidChanged"]; 269 else [defaults setBool:NO forKey:@"NBAPPUuidChanged"];
...@@ -5678,6 +5695,11 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) ...@@ -5678,6 +5695,11 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
5678 self.webId = [context valueForKey:@"web_id"]; 5695 self.webId = [context valueForKey:@"web_id"];
5679 [WLKeychain setString:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forKey:@"old_identifier_for_vendor"]; 5696 [WLKeychain setString:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forKey:@"old_identifier_for_vendor"];
5680 5697
5698 + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
5699 + [defaults setObject:[context valueForKey:@"api_key"] forKey:@"NBAPIKeyUD"];
5700 + [defaults setObject:[context valueForKey:@"web_id"] forKey:@"NBWebIDUD"];
5701 + [[NSUserDefaults standardUserDefaults] synchronize];
5702 +
5681 [_pendingOperationsQueue setSuspended:![self isRegistrationValid]]; 5703 [_pendingOperationsQueue setSuspended:![self isRegistrationValid]];
5682 if (success) { 5704 if (success) {
5683 NSDictionary* successCallback = [[NSMutableDictionary alloc] init]; 5705 NSDictionary* successCallback = [[NSMutableDictionary alloc] init];
......