mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-09 22:35:56 +05:45
* feat(remote-config): add network scaffolding for GET /v2/config endpoint Adds RemoteConfigResponse model, GetRemoteConfigOperation, RemoteConfigAPI, and wires everything into Backend. Unknown topic keys in the manifest are silently dropped for forward compatibility. Mirrors Android PR #3435. * fix(remote-config): use lowercase "default" variant key in test fixtures Aligns with Android convention (DEFAULT_ENTRY_ID = "default") established in purchases-android PR #3437. * test(remote-config): add snapshot files for all CI OS versions BackendGetRemoteConfigTests was only recording snapshots for iOS 26. CI also runs tests on iOS 14/15/16/17/18, tvOS 18, macOS, and watchOS, each of which requires its own snapshot file. Derived from existing snapshot patterns in BackendGetRewardVerificationStatusTests. * fix(remote-config): log warning when unknown topic key is received Follows the codebase convention of logging unknown backend values (e.g. WorkflowsResponse unknown_workflow_trigger_type) rather than silently dropping them. * refactor(remote-config): rename wireKey to rawValue, add WIP comment for signature verification Aligns Topic with Swift's RawRepresentable convention and matches the Android SDK's comment indicating signature verification will be enabled once the remote config endpoint is finalized. * refactor(remote-config): enable etag and simplify HTTPRequestPath cases
42 lines
1.2 KiB
Swift
42 lines
1.2 KiB
Swift
//
|
|
// RemoteConfigAPI.swift
|
|
// RevenueCat
|
|
//
|
|
// Created by Rick van der Linden on 27/05/2026.
|
|
// Copyright © 2026 RevenueCat, Inc. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
class RemoteConfigAPI {
|
|
|
|
typealias RemoteConfigResponseHandler = Backend.ResponseHandler<RemoteConfigResponse>
|
|
|
|
private let callbackCache: CallbackCache<RemoteConfigCallback>
|
|
private let backendConfig: BackendConfiguration
|
|
|
|
init(backendConfig: BackendConfiguration) {
|
|
self.backendConfig = backendConfig
|
|
self.callbackCache = .init()
|
|
}
|
|
|
|
func getRemoteConfig(
|
|
isAppBackgrounded: Bool,
|
|
completion: @escaping RemoteConfigResponseHandler
|
|
) {
|
|
let factory = GetRemoteConfigOperation.createFactory(
|
|
configuration: self.backendConfig,
|
|
callbackCache: self.callbackCache
|
|
)
|
|
|
|
let callback = RemoteConfigCallback(cacheKey: factory.cacheKey, completion: completion)
|
|
let cacheStatus = self.callbackCache.add(callback)
|
|
|
|
self.backendConfig.addCacheableOperation(
|
|
with: factory,
|
|
delay: .default(forBackgroundedApp: isAppBackgrounded),
|
|
cacheStatus: cacheStatus
|
|
)
|
|
}
|
|
|
|
}
|