mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
When compiling with Xcode 16, we started throwing a bunch of new warnings. Here's a list and explanation of each: - The most common one was needing to explicitly restate the @unchecked Sendable conformance from a parent class. - There were a couple switches where a new entry was added in tvOS but only for iOS 18, and needed to add it to make it exhaustive. - There we a couple of places where we were adding a protocol conformance to a class from a different module e.g. extension DispatchTimeInterval: Comparable. This is considered unsafe now because the owners of the module could add the conformance later. Solved by removing the conformance which wasn't being used widely in the codebase, only in tests. - Finally there was a class where we were capturing SKRequest and SKProductsRequest instances in a sendable block, but only to either log something, or use them as dictionary key, so I just made the classes Sendable (with the new @retroactice attribute because they belong to a different module)
91 lines
2.9 KiB
Swift
91 lines
2.9 KiB
Swift
//
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// GetCustomerCenterConfigOperation.swift
|
|
//
|
|
//
|
|
// Created by Cesar de la Vega on 31/5/24.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
final class GetCustomerCenterConfigOperation: CacheableNetworkOperation {
|
|
|
|
private let customerCenterConfigCallbackCache: CallbackCache<CustomerCenterConfigCallback>
|
|
private let configuration: AppUserConfiguration
|
|
|
|
static func createFactory(
|
|
configuration: UserSpecificConfiguration,
|
|
callbackCache: CallbackCache<CustomerCenterConfigCallback>
|
|
) -> CacheableNetworkOperationFactory<GetCustomerCenterConfigOperation> {
|
|
return .init({ cacheKey in
|
|
.init(
|
|
configuration: configuration,
|
|
customerCenterConfigCallbackCache: callbackCache,
|
|
cacheKey: cacheKey
|
|
)
|
|
},
|
|
individualizedCacheKeyPart: configuration.appUserID)
|
|
}
|
|
|
|
private init(configuration: UserSpecificConfiguration,
|
|
customerCenterConfigCallbackCache: CallbackCache<CustomerCenterConfigCallback>,
|
|
cacheKey: String) {
|
|
self.configuration = configuration
|
|
self.customerCenterConfigCallbackCache = customerCenterConfigCallbackCache
|
|
|
|
super.init(configuration: configuration, cacheKey: cacheKey)
|
|
}
|
|
|
|
override func begin(completion: @escaping () -> Void) {
|
|
self.getCustomerCenterConfig(completion: completion)
|
|
}
|
|
|
|
}
|
|
|
|
// Restating inherited @unchecked Sendable from Foundation's Operation
|
|
extension GetCustomerCenterConfigOperation: @unchecked Sendable {}
|
|
|
|
private extension GetCustomerCenterConfigOperation {
|
|
|
|
func getCustomerCenterConfig(completion: @escaping () -> Void) {
|
|
let appUserID = self.configuration.appUserID
|
|
|
|
guard appUserID.isNotEmpty else {
|
|
self.customerCenterConfigCallbackCache.performOnAllItemsAndRemoveFromCache(
|
|
withCacheable: self
|
|
) { callback in
|
|
callback.completion(.failure(.missingAppUserID()))
|
|
}
|
|
completion()
|
|
|
|
return
|
|
}
|
|
|
|
let request = HTTPRequest(method: .get, path: .getCustomerCenterConfig(appUserID: appUserID))
|
|
|
|
httpClient.perform(request) { (response: VerifiedHTTPResponse<CustomerCenterConfigResponse>.Result) in
|
|
defer {
|
|
completion()
|
|
}
|
|
|
|
self.customerCenterConfigCallbackCache.performOnAllItemsAndRemoveFromCache(
|
|
withCacheable: self
|
|
) { callback in
|
|
callback.completion(
|
|
response
|
|
.map { $0.body }
|
|
.mapError(BackendError.networkError)
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|