Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qonversion and Store Kit Products logic #505

Merged
merged 12 commits into from
Apr 29, 2024
76 changes: 60 additions & 16 deletions Qonversion.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
6A840E062BD6AE5700E5E8E3 /* RemoteConfigManagerInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A840E052BD6AE5700E5E8E3 /* RemoteConfigManagerInterface.swift */; };
6A840E092BD6AE7C00E5E8E3 /* EmptyApiResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A840E082BD6AE7C00E5E8E3 /* EmptyApiResponse.swift */; };
6A840E0B2BD6AEE500E5E8E3 /* ApiError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A840E0A2BD6AEE500E5E8E3 /* ApiError.swift */; };
6A840E0E2BD6B2F600E5E8E3 /* RemoteConfigService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A840E0D2BD6B2F600E5E8E3 /* RemoteConfigService.swift */; };
6A840E102BD6B30B00E5E8E3 /* RemoteConfigServiceInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A840E0F2BD6B30B00E5E8E3 /* RemoteConfigServiceInterface.swift */; };
70B4E96E2BD92B9C00EE808C /* StoreKitFacadeDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70B4E96D2BD92B9C00EE808C /* StoreKitFacadeDelegate.swift */; };
70B4E9702BD940F700EE808C /* StoreProductWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70B4E96F2BD940F700EE808C /* StoreProductWrapper.swift */; };
70B4E9762BDAA7C300EE808C /* RemoteConfigService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70B4E9732BDAA7C300EE808C /* RemoteConfigService.swift */; };
70B4E9772BDAA7C300EE808C /* RemoteConfigServiceInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70B4E9742BDAA7C300EE808C /* RemoteConfigServiceInterface.swift */; };
70CD92F62BC6E22B0039D65C /* MiscAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70CD929B2BC6E22B0039D65C /* MiscAssembly.swift */; };
70CD92F72BC6E22B0039D65C /* QonversionAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70CD929C2BC6E22B0039D65C /* QonversionAssembly.swift */; };
70CD92F82BC6E22B0039D65C /* ServicesAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70CD929D2BC6E22B0039D65C /* ServicesAssembly.swift */; };
Expand Down Expand Up @@ -94,6 +96,11 @@
70D877242B8F5B370059AA2B /* Qonversion.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 70F163A22B6D0D3D00033BEF /* Qonversion.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
70EA734C2BD025F500B0DFDA /* Currency.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70EA734B2BD025F500B0DFDA /* Currency.swift */; };
70EA734E2BD0261300B0DFDA /* Storefront.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70EA734D2BD0261300B0DFDA /* Storefront.swift */; };
70EA73512BD12C7B00B0DFDA /* ProductsServiceInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70EA73502BD12C7B00B0DFDA /* ProductsServiceInterface.swift */; };
70EA73532BD12C8000B0DFDA /* ProductsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70EA73522BD12C8000B0DFDA /* ProductsService.swift */; };
70EA73552BD12CA500B0DFDA /* Product.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70EA73542BD12CA500B0DFDA /* Product.swift */; };
70EA735D2BD6B66300B0DFDA /* ProductsManagerInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70EA735C2BD6B66300B0DFDA /* ProductsManagerInterface.swift */; };
70EA735F2BD6B68000B0DFDA /* ProductsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70EA735E2BD6B68000B0DFDA /* ProductsManager.swift */; };
7169ED74E32501B128C51E9D /* Pods_Qonversion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3058D2FCF5492D5398F1D64F /* Pods_Qonversion.framework */; };
D265F4B90C3180117593732E /* Pods_Sample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A982E3A335EC2527556D692D /* Pods_Sample.framework */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -134,12 +141,14 @@
6A840E052BD6AE5700E5E8E3 /* RemoteConfigManagerInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteConfigManagerInterface.swift; sourceTree = "<group>"; };
6A840E082BD6AE7C00E5E8E3 /* EmptyApiResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyApiResponse.swift; sourceTree = "<group>"; };
6A840E0A2BD6AEE500E5E8E3 /* ApiError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiError.swift; sourceTree = "<group>"; };
6A840E0D2BD6B2F600E5E8E3 /* RemoteConfigService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteConfigService.swift; sourceTree = "<group>"; };
6A840E0F2BD6B30B00E5E8E3 /* RemoteConfigServiceInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteConfigServiceInterface.swift; sourceTree = "<group>"; };
6ABCBDF42B8CE268003DB107 /* PropertiesStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PropertiesStorage.swift; sourceTree = "<group>"; };
6ABCBDF62B8CE298003DB107 /* UserPropertiesStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserPropertiesStorage.swift; sourceTree = "<group>"; };
6ABCBDF82B8DD7A2003DB107 /* SendUserPropertiesResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendUserPropertiesResult.swift; sourceTree = "<group>"; };
701A06AF0F488249669E14C2 /* Pods-Qonversion.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Qonversion.release.xcconfig"; path = "Target Support Files/Pods-Qonversion/Pods-Qonversion.release.xcconfig"; sourceTree = "<group>"; };
70B4E96D2BD92B9C00EE808C /* StoreKitFacadeDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreKitFacadeDelegate.swift; sourceTree = "<group>"; };
70B4E96F2BD940F700EE808C /* StoreProductWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreProductWrapper.swift; sourceTree = "<group>"; };
70B4E9732BDAA7C300EE808C /* RemoteConfigService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteConfigService.swift; sourceTree = "<group>"; };
70B4E9742BDAA7C300EE808C /* RemoteConfigServiceInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteConfigServiceInterface.swift; sourceTree = "<group>"; };
70CD929B2BC6E22B0039D65C /* MiscAssembly.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MiscAssembly.swift; sourceTree = "<group>"; };
70CD929C2BC6E22B0039D65C /* QonversionAssembly.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QonversionAssembly.swift; sourceTree = "<group>"; };
70CD929D2BC6E22B0039D65C /* ServicesAssembly.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServicesAssembly.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -228,6 +237,11 @@
70D877892BA19B100059AA2B /* ServicesAssembly.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServicesAssembly.swift; sourceTree = "<group>"; };
70EA734B2BD025F500B0DFDA /* Currency.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Currency.swift; sourceTree = "<group>"; };
70EA734D2BD0261300B0DFDA /* Storefront.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Storefront.swift; sourceTree = "<group>"; };
70EA73502BD12C7B00B0DFDA /* ProductsServiceInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductsServiceInterface.swift; sourceTree = "<group>"; };
70EA73522BD12C8000B0DFDA /* ProductsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductsService.swift; sourceTree = "<group>"; };
70EA73542BD12CA500B0DFDA /* Product.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Product.swift; sourceTree = "<group>"; };
70EA735C2BD6B66300B0DFDA /* ProductsManagerInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductsManagerInterface.swift; sourceTree = "<group>"; };
70EA735E2BD6B68000B0DFDA /* ProductsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductsManager.swift; sourceTree = "<group>"; };
70F163A22B6D0D3D00033BEF /* Qonversion.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Qonversion.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A982E3A335EC2527556D692D /* Pods_Sample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Sample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -272,15 +286,6 @@
path = Entities;
sourceTree = "<group>";
};
6A840E0C2BD6B2ED00E5E8E3 /* RemoteConfig */ = {
isa = PBXGroup;
children = (
6A840E0D2BD6B2F600E5E8E3 /* RemoteConfigService.swift */,
6A840E0F2BD6B30B00E5E8E3 /* RemoteConfigServiceInterface.swift */,
);
path = RemoteConfig;
sourceTree = "<group>";
};
6ABCBE0F2B91C86D003DB107 /* Recovered References */ = {
isa = PBXGroup;
children = (
Expand All @@ -298,6 +303,15 @@
name = "Recovered References";
sourceTree = "<group>";
};
70B4E9752BDAA7C300EE808C /* RemoteConfigService */ = {
isa = PBXGroup;
children = (
70B4E9732BDAA7C300EE808C /* RemoteConfigService.swift */,
70B4E9742BDAA7C300EE808C /* RemoteConfigServiceInterface.swift */,
);
path = RemoteConfigService;
sourceTree = "<group>";
};
70CD929E2BC6E22B0039D65C /* Assemblies */ = {
isa = PBXGroup;
children = (
Expand All @@ -319,6 +333,8 @@
70CD92A22BC6E22B0039D65C /* UserProperties.swift */,
70CD92A32BC6E22B0039D65C /* UserProperty.swift */,
70CD92A42BC6E22B0039D65C /* UserPropertyKey.swift */,
70EA73542BD12CA500B0DFDA /* Product.swift */,
70B4E96F2BD940F700EE808C /* StoreProductWrapper.swift */,
6A840DF82BD6ADAD00E5E8E3 /* Experiment.swift */,
6A840DFC2BD6ADD700E5E8E3 /* RemoteConfig.swift */,
6A840DFE2BD6ADEA00E5E8E3 /* RemoteConfigList.swift */,
Expand Down Expand Up @@ -348,6 +364,7 @@
70CD92AD2BC6E22B0039D65C /* Managers */ = {
isa = PBXGroup;
children = (
70EA735B2BD6B63300B0DFDA /* ProductsManager */,
6A840E022BD6AE2E00E5E8E3 /* RemoteConfig */,
70CD92A82BC6E22B0039D65C /* Device */,
70CD92AC2BC6E22B0039D65C /* UserProperties */,
Expand Down Expand Up @@ -505,7 +522,8 @@
70CD92DB2BC6E22B0039D65C /* Services */ = {
isa = PBXGroup;
children = (
6A840E0C2BD6B2ED00E5E8E3 /* RemoteConfig */,
70B4E9752BDAA7C300EE808C /* RemoteConfigService */,
70EA734F2BD12C7300B0DFDA /* ProductsService */,
70CD92D72BC6E22B0039D65C /* Device */,
70CD92DA2BC6E22B0039D65C /* UserService */,
);
Expand All @@ -517,6 +535,7 @@
children = (
70CD92DC2BC6E22B0039D65C /* StoreKitFacade.swift */,
70CD92DD2BC6E22B0039D65C /* StoreKitFacadeInterface.swift */,
70B4E96D2BD92B9C00EE808C /* StoreKitFacadeDelegate.swift */,
70CD92DE2BC6E22B0039D65C /* StoreKitMapper.swift */,
70CD92DF2BC6E22B0039D65C /* StoreKitMapperInterface.swift */,
70CD92E02BC6E22B0039D65C /* StoreKitOldWrapper.swift */,
Expand Down Expand Up @@ -588,6 +607,24 @@
path = Sample;
sourceTree = "<group>";
};
70EA734F2BD12C7300B0DFDA /* ProductsService */ = {
isa = PBXGroup;
children = (
70EA73502BD12C7B00B0DFDA /* ProductsServiceInterface.swift */,
70EA73522BD12C8000B0DFDA /* ProductsService.swift */,
);
path = ProductsService;
sourceTree = "<group>";
};
70EA735B2BD6B63300B0DFDA /* ProductsManager */ = {
isa = PBXGroup;
children = (
70EA735C2BD6B66300B0DFDA /* ProductsManagerInterface.swift */,
70EA735E2BD6B68000B0DFDA /* ProductsManager.swift */,
);
path = ProductsManager;
sourceTree = "<group>";
};
70F163982B6D0D3D00033BEF = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -801,9 +838,10 @@
70CD93082BC6E22B0039D65C /* HeadersBuilder.swift in Sources */,
6A840E062BD6AE5700E5E8E3 /* RemoteConfigManagerInterface.swift in Sources */,
70CD93372BC6E22B0039D65C /* StorageConstants.swift in Sources */,
6A840E102BD6B30B00E5E8E3 /* RemoteConfigServiceInterface.swift in Sources */,
70CD931E2BC6E22B0039D65C /* DeviceService.swift in Sources */,
70EA73532BD12C8000B0DFDA /* ProductsService.swift in Sources */,
70CD932C2BC6E22B0039D65C /* ConcurrencyExtensions.swift in Sources */,
70EA735F2BD6B68000B0DFDA /* ProductsManager.swift in Sources */,
70EA734C2BD025F500B0DFDA /* Currency.swift in Sources */,
70CD92FD2BC6E22B0039D65C /* UserProperty.swift in Sources */,
70EA734E2BD0261300B0DFDA /* Storefront.swift in Sources */,
Expand All @@ -820,17 +858,22 @@
70CD92F62BC6E22B0039D65C /* MiscAssembly.swift in Sources */,
70CD93022BC6E22B0039D65C /* UserPropertiesManager.swift in Sources */,
70CD93012BC6E22B0039D65C /* SendUserPropertiesResult.swift in Sources */,
70B4E9762BDAA7C300EE808C /* RemoteConfigService.swift in Sources */,
70B4E96E2BD92B9C00EE808C /* StoreKitFacadeDelegate.swift in Sources */,
70CD930A2BC6E22B0039D65C /* NetworkErrorHandler.swift in Sources */,
70CD92F82BC6E22B0039D65C /* ServicesAssembly.swift in Sources */,
70CD93032BC6E22B0039D65C /* UserPropertiesManagerInterface.swift in Sources */,
70CD93252BC6E22B0039D65C /* StoreKitMapperInterface.swift in Sources */,
6A840E042BD6AE4300E5E8E3 /* RemoteConfigManager.swift in Sources */,
70CD93202BC6E22B0039D65C /* UserService.swift in Sources */,
70EA73552BD12CA500B0DFDA /* Product.swift in Sources */,
70CD93232BC6E22B0039D65C /* StoreKitFacadeInterface.swift in Sources */,
70CD93192BC6E22B0039D65C /* LocalStorageInterface.swift in Sources */,
70EA735D2BD6B66300B0DFDA /* ProductsManagerInterface.swift in Sources */,
70CD932A2BC6E22B0039D65C /* StoreKitWrapperDelegate.swift in Sources */,
70CD93072BC6E22B0039D65C /* Header.swift in Sources */,
70CD93122BC6E22B0039D65C /* RequestProcessor.swift in Sources */,
70EA73512BD12C7B00B0DFDA /* ProductsServiceInterface.swift in Sources */,
70CD93062BC6E22B0039D65C /* QonversionErrorType.swift in Sources */,
70CD932D2BC6E22B0039D65C /* IncrementalDelayCalculator.swift in Sources */,
70CD93102BC6E22B0039D65C /* Request.swift in Sources */,
Expand All @@ -841,6 +884,7 @@
70CD930F2BC6E22B0039D65C /* RateLimiterInterface.swift in Sources */,
70CD931F2BC6E22B0039D65C /* DeviceServiceInterface.swift in Sources */,
70CD93362BC6E22B0039D65C /* Qonversion.swift in Sources */,
70B4E9702BD940F700EE808C /* StoreProductWrapper.swift in Sources */,
6A840DFD2BD6ADD700E5E8E3 /* RemoteConfig.swift in Sources */,
70CD93342BC6E22B0039D65C /* Qonversion.docc in Sources */,
70CD92FB2BC6E22B0039D65C /* User.swift in Sources */,
Expand All @@ -857,8 +901,8 @@
70CD932B2BC6E22B0039D65C /* StoreKitWrapperInterface.swift in Sources */,
70CD93162BC6E22B0039D65C /* ResponseDecoder.swift in Sources */,
70CD93262BC6E22B0039D65C /* StoreKitOldWrapper.swift in Sources */,
6A840E0E2BD6B2F600E5E8E3 /* RemoteConfigService.swift in Sources */,
6A840E092BD6AE7C00E5E8E3 /* EmptyApiResponse.swift in Sources */,
70B4E9772BDAA7C300EE808C /* RemoteConfigServiceInterface.swift in Sources */,
70CD93242BC6E22B0039D65C /* StoreKitMapper.swift in Sources */,
70CD931C2BC6E22B0039D65C /* DeviceInfoCollector.swift in Sources */,
70CD93112BC6E22B0039D65C /* RequestType.swift in Sources */,
Expand Down
5 changes: 5 additions & 0 deletions Sources/Assemblies/MiscAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation
import OSLog
import StoreKit

fileprivate enum SDKLevelConstants: String {
case version = "1.0"
Expand Down Expand Up @@ -111,4 +112,8 @@ final class MiscAssembly {

return headersBuilder
}

func paymentQueue() -> SKPaymentQueue {
return SKPaymentQueue.default()
}
}
12 changes: 12 additions & 0 deletions Sources/Assemblies/QonversionAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ final class QonversionAssembly {
return deviceManager
}

func productsManager() -> ProductsManagerInterface {
let productsService: ProductsServiceInterface = servicesAssembly.productsService()
let storeKitFacade: StoreKitFacade = servicesAssembly.storeKitFacade()
let localStorage: LocalStorageInterface = miscAssembly.localStorage()
let logger: LoggerWrapper = miscAssembly.loggerWrapper()
let productsManager = ProductsManager(productsService: productsService, storeKitFacade: storeKitFacade, localStorage: localStorage, logger: logger)

storeKitFacade.delegate = productsManager

return productsManager
}

func remoteConfigManager() -> RemoteConfigManagerInterface {
let remoteConfigService = servicesAssembly.remoteConfigService()
let logger: LoggerWrapper = miscAssembly.loggerWrapper()
Expand Down
47 changes: 47 additions & 0 deletions Sources/Assemblies/ServicesAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,53 @@ final class ServicesAssembly {
return userService
}

func productsService() -> ProductsServiceInterface {
let requestProcessor = requestProcessor()
let productsService = ProductsService(requestProcessor: requestProcessor, internalConfig: miscAssembly.internalConfig)

return productsService
}

func storeKitMapper() -> StoreKitMapperInterface {
let mapper = StoreKitMapper()

return mapper
}

func storeKitFacade() -> StoreKitFacade {
let mapper: StoreKitMapperInterface = storeKitMapper()
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, visionOS 1.0, *) {
let wrapper: StoreKitWrapper = storeKitWrapper()

let storeKitFacade = StoreKitFacade(storeKitWrapper: wrapper, storeKitMapper: mapper)

wrapper.delegate = storeKitFacade

return storeKitFacade
} else {
let wrapper: StoreKitOldWrapper = storeKitOldWrapper()

let storeKitFacade = StoreKitFacade(storeKitOldWrapper: wrapper, storeKitMapper: mapper)
wrapper.delegate = storeKitFacade

return storeKitFacade
}

}

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, visionOS 1.0, *)
func storeKitWrapper() -> StoreKitWrapper {
let storeKitWrapper = StoreKitWrapper()

return storeKitWrapper
}

func storeKitOldWrapper() -> StoreKitOldWrapper {
let storeKitOldWrapper = StoreKitOldWrapper(paymentQueue: miscAssembly.paymentQueue())

return storeKitOldWrapper
}

func deviceService() -> DeviceServiceInterface {
let requestProcessor: RequestProcessorInterface = requestProcessor()
let localStorage: LocalStorageInterface = miscAssembly.localStorage()
Expand Down
Loading
Loading