Skip to content

Commit

Permalink
Fixed nil file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jun 27, 2024
1 parent a94b744 commit 5c0cfd7
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 116 deletions.
8 changes: 4 additions & 4 deletions Qonversion.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
70283DF729F66FAC00D138BC /* PurchasesMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70283DF629F66FAC00D138BC /* PurchasesMapper.swift */; };
702BF8B629531A68000B6C3E /* QONScreenCustomizationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 702BF8B529531A68000B6C3E /* QONScreenCustomizationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
702DBDEC2A3216C900D590D0 /* QONExperiment+Protected.h in Headers */ = {isa = PBXBuildFile; fileRef = 702DBDEB2A3216C900D590D0 /* QONExperiment+Protected.h */; };
703666202C17512200B0C503 /* qonversion_fallbacks.json in Resources */ = {isa = PBXBuildFile; fileRef = 7036661F2C17512200B0C503 /* qonversion_fallbacks.json */; };
7042E7822C1C5DB700C5AECF /* QONFallbackService.h in Headers */ = {isa = PBXBuildFile; fileRef = 7042E77F2C1C5DB700C5AECF /* QONFallbackService.h */; };
7042E7832C1C5DB700C5AECF /* QONFallbackService.m in Sources */ = {isa = PBXBuildFile; fileRef = 7042E7802C1C5DB700C5AECF /* QONFallbackService.m */; };
7042E7872C1C5DDE00C5AECF /* QONFallbackMapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 7042E7842C1C5DDE00C5AECF /* QONFallbackMapper.h */; };
Expand All @@ -92,6 +91,7 @@
70B9A9F1297AB8A700BD30FD /* QONAutomationsNavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 70B9A9EF297AB8A700BD30FD /* QONAutomationsNavigationController.h */; };
70B9A9F2297AB8A700BD30FD /* QONAutomationsNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 70B9A9F0297AB8A700BD30FD /* QONAutomationsNavigationController.m */; };
70BAB0642B58306E00D19A6A /* expected_entitlements.json in Resources */ = {isa = PBXBuildFile; fileRef = 70893C992B3EC136002C6B82 /* expected_entitlements.json */; };
70CB7CE42C2DB37A00241FF1 /* qonversion_fallbacks.json in Resources */ = {isa = PBXBuildFile; fileRef = 70CB7CE32C2DB37900241FF1 /* qonversion_fallbacks.json */; };
70D05A8E29C9FC1600EA5DDF /* QONRemoteConfigManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 70D05A8C29C9FC1600EA5DDF /* QONRemoteConfigManager.h */; };
70D05A8F29C9FC1600EA5DDF /* QONRemoteConfigManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 70D05A8D29C9FC1600EA5DDF /* QONRemoteConfigManager.m */; };
70D05A9329C9FF3C00EA5DDF /* QONRemoteConfigService.h in Headers */ = {isa = PBXBuildFile; fileRef = 70D05A9129C9FF3C00EA5DDF /* QONRemoteConfigService.h */; };
Expand Down Expand Up @@ -390,7 +390,6 @@
70283DF629F66FAC00D138BC /* PurchasesMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PurchasesMapper.swift; sourceTree = "<group>"; };
702BF8B529531A68000B6C3E /* QONScreenCustomizationDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QONScreenCustomizationDelegate.h; sourceTree = "<group>"; };
702DBDEB2A3216C900D590D0 /* QONExperiment+Protected.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "QONExperiment+Protected.h"; sourceTree = "<group>"; };
7036661F2C17512200B0C503 /* qonversion_fallbacks.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = qonversion_fallbacks.json; sourceTree = "<group>"; };
7042E77F2C1C5DB700C5AECF /* QONFallbackService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QONFallbackService.h; sourceTree = "<group>"; };
7042E7802C1C5DB700C5AECF /* QONFallbackService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QONFallbackService.m; sourceTree = "<group>"; };
7042E7842C1C5DDE00C5AECF /* QONFallbackMapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QONFallbackMapper.h; sourceTree = "<group>"; };
Expand All @@ -414,6 +413,7 @@
70B917662B34284200BF0689 /* QONTransaction+Protected.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "QONTransaction+Protected.h"; sourceTree = "<group>"; };
70B9A9EF297AB8A700BD30FD /* QONAutomationsNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QONAutomationsNavigationController.h; sourceTree = "<group>"; };
70B9A9F0297AB8A700BD30FD /* QONAutomationsNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QONAutomationsNavigationController.m; sourceTree = "<group>"; };
70CB7CE32C2DB37900241FF1 /* qonversion_fallbacks.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = qonversion_fallbacks.json; sourceTree = "<group>"; };
70D05A8C29C9FC1600EA5DDF /* QONRemoteConfigManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QONRemoteConfigManager.h; sourceTree = "<group>"; };
70D05A8D29C9FC1600EA5DDF /* QONRemoteConfigManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QONRemoteConfigManager.m; sourceTree = "<group>"; };
70D05A9129C9FF3C00EA5DDF /* QONRemoteConfigService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QONRemoteConfigService.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -641,7 +641,7 @@
454EF63D24E5CC580070581E /* Sample */ = {
isa = PBXGroup;
children = (
7036661F2C17512200B0C503 /* qonversion_fallbacks.json */,
70CB7CE32C2DB37900241FF1 /* qonversion_fallbacks.json */,
456215C8257D6AF800548A3D /* Sample.entitlements */,
454EF63E24E5CC580070581E /* AppDelegate.swift */,
454EF64224E5CC590070581E /* ViewController.swift */,
Expand Down Expand Up @@ -1898,7 +1898,7 @@
454EF64B24E5CC5A0070581E /* LaunchScreen.storyboard in Resources */,
894278822759334D00A8A6EC /* GoogleService-Info.plist in Resources */,
454EF64824E5CC5A0070581E /* Assets.xcassets in Resources */,
703666202C17512200B0C503 /* qonversion_fallbacks.json in Resources */,
70CB7CE42C2DB37A00241FF1 /* qonversion_fallbacks.json in Resources */,
454EF64624E5CC590070581E /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
272 changes: 160 additions & 112 deletions Sample/qonversion_fallbacks.json
Original file line number Diff line number Diff line change
@@ -1,121 +1,169 @@
{
"products": [
"products": [
{
"id": "weekly",
"duration": 0,
"store_id": "io.qonversion.weekly",
"type": 1
},
{
"id": "consumable",
"duration": null,
"store_id": "io.qonversion.consumable",
"type": 2
},
{
"id": "subs_plus_trial",
"duration": 1,
"store_id": "io.qonversion.subs.monthly.plus.trial",
"type": 0
},
{
"id": "annual",
"duration": 4,
"store_id": "io.qonversion.subs.annual",
"type": 0
},
{
"id": "in_app",
"duration": null,
"store_id": "io.qonversion.nonconsumable",
"type": 2
}
],
"offerings": [
{
"id": "main",
"tag": 1,
"products": [
{
"duration": 4,
"id": "annual",
"store_id": "io.qonversion.subs.annual",
"type": 0
"id": "weekly",
"duration": 0,
"store_id": "io.qonversion.weekly",
"type": 1
},
{
"duration": 1,
"id": "subs_plus_trial",
"store_id": "io.qonversion.subs.monthly.plus.trial",
"type": 0
"id": "annual",
"duration": 4,
"store_id": "io.qonversion.subs.annual",
"type": 0
},
{
"duration": 0,
"id": "weekly",
"store_id": "io.qonversion.weekly",
"type": 1
"id": "consumable",
"duration": null,
"store_id": "io.qonversion.consumable",
"type": 2
}
],
"offerings": [
{
"id": "main",
"products": [
{
"duration": 0,
"id": "weekly",
"store_id": "io.qonversion.weekly",
"type": 1
},
{
"duration": 4,
"id": "annual",
"store_id": "io.qonversion.subs.annual",
"type": 0
},
{
"duration": null,
"id": "consumable",
"store_id": "io.qonversion.consumable",
"type": 2
}
],
"tag": 1
},
{
"id": "discounted_offer",
"products": [],
"tag": 0
}
],
"products_permissions": {
"annual": [
"standart",
"sample"
],
"annual": [
"standart"
],
"subs_plus_trial": [
"standart"
],
"weekly": [
"plus"
]
]
},
"remote_config_list": [
{
"experiment": null,
"payload": {
"CTA": "Start you trial",
"CTA_color": "red",
"main_image": "111",
"product_id": "123123123123123",
"show_close_button": 1
},
"source": {
"assignment_type": "auto",
"context_key": "",
"name": "Default settings",
"type": "remote_configuration",
"uid": "12feb1dd-8096-47bc-a5a1-443fd2828ecc"
}
},
{
"experiment": null,
"payload": {
"CTA": "New test",
"CTA_color": "blue",
"main_image": "1111",
"product_id": "2332",
"show_close_button": 1
},
"source": {
"assignment_type": "auto",
"context_key": "new_test",
"name": "Default settings",
"type": "remote_configuration",
"uid": "12feb1dd-8096-47bc-a5a1-443fd2828ecc"
}
},
{
"experiment": null,
"payload": {
"CTA": "One more test",
"CTA_color": "yellow",
"main_image": "1111",
"product_id": "2332",
"show_close_button": 1
},
"source": {
"assignment_type": "auto",
"context_key": "one_more_test",
"name": "Default settings",
"type": "remote_configuration",
"uid": "12feb1dd-8096-47bc-a5a1-443fd2828ecc"
}
{
"id": "discounted_offer",
"tag": 0,
"products": []
}
],
"products_permissions": [
{
"weekly": [
"plus"
]
},
{
"consumable": []
},
{
"subs_plus_trial": [
"standart"
]
},
{
"annual": [
"standart",
"sample"
]
},
{
"in_app": [
"Premium Movies"
]
}
],
"remote_config_list": [
{
"experiment": null,
"payload": {
"CTA": "Start Trial",
"CTA_color": "#307BF6",
"main_image": "[IMAGE_URL]",
"product_id": "prod_7d_trial_5.99",
"show_close_button": true
},
"source": {
"assignment_type": "auto",
"context_key": "main_paywall",
"name": "default paywall",
"type": "remote_configuration",
"uid": "0dcb1bd9-9bc3-4668-84aa-4540d1042c5d"
}
},
{
"experiment": null,
"payload": {
"CTA": "Start you trial",
"CTA_color": "red",
"main_image": "111",
"product_id": "123123123123123",
"show_close_button": true
},
"source": {
"assignment_type": "auto",
"context_key": "",
"name": "Default settings",
"type": "remote_configuration",
"uid": "12feb1dd-8096-47bc-a5a1-443fd2828ecc"
}
},
{
"experiment": null,
"payload": {
"test_key": "test_value"
},
"source": {
"assignment_type": "auto",
"context_key": "test_context_key",
"name": "Test with context key1",
"type": "remote_configuration",
"uid": "c5077ec4-acf4-41ea-8b43-05114be5d7ce"
}
},
{
"experiment": null,
"payload": {
"test_key_2": "test_value_2"
},
"source": {
"assignment_type": "auto",
"context_key": "test_context_key_2",
"name": "Test with context key2 - copy",
"type": "remote_configuration",
"uid": "1c000f2a-2f4b-4736-b5dd-75b13bf73deb"
}
},
{
"experiment": null,
"payload": {
"bool": true,
"json": {
"key": "value"
}
]
}
},
"source": {
"assignment_type": "auto",
"context_key": "swift_key ",
"name": "Swift",
"type": "remote_configuration",
"uid": "9f85d738-56d8-4f6c-b54a-c08658be2cb4"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ - (QONFallbackObject * _Nullable)obtainFallbackData {

NSData *fileData = [NSData dataWithContentsOfFile:pathToFile];

if (!fileData) {
return nil;
}

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

QONFallbackObject *resultObject = [self.mapper mapFallbackData:resultMap];
Expand Down

0 comments on commit 5c0cfd7

Please sign in to comment.