Skip to content

Commit

Permalink
Merge pull request #526 from qonversion/feature/fallbacksUpdate
Browse files Browse the repository at this point in the history
Updated fallbacks fetching logic
  • Loading branch information
suriksarkisyan authored Jul 15, 2024
2 parents 4ae334a + 1d880c8 commit fdd8e28
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,20 @@ - (QONFallbackObject * _Nullable)obtainFallbackData {
NSData *fileData = [NSData dataWithContentsOfFile:pathToFile];

if (!fileData) {
return nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = paths.firstObject;

if (documentsPath) {
NSString *filePath = [documentsPath stringByAppendingPathComponent:kFallbacksFileName];

if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
fileData = [NSData dataWithContentsOfFile:filePath];
} else {
return nil;
}
} else {
return nil;
}
}

NSDictionary *resultMap = [NSJSONSerialization JSONObjectWithData:fileData options:kNilOptions error:nil];
Expand Down

0 comments on commit fdd8e28

Please sign in to comment.