From 1d880c861c0cc062370b397d93f71db97a027be3 Mon Sep 17 00:00:00 2001 From: Surik Date: Mon, 15 Jul 2024 19:51:24 +0400 Subject: [PATCH] Updated fallbacks fetching logic --- .../QONFallbackService/QONFallbackService.m | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Sources/Qonversion/Qonversion/Services/QONFallbackService/QONFallbackService.m b/Sources/Qonversion/Qonversion/Services/QONFallbackService/QONFallbackService.m index 99efa822..5f58b1e5 100644 --- a/Sources/Qonversion/Qonversion/Services/QONFallbackService/QONFallbackService.m +++ b/Sources/Qonversion/Qonversion/Services/QONFallbackService/QONFallbackService.m @@ -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];