-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: configure ios user agent client source
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import CioInternalCommon | ||
|
||
/// Extension on `SdkClient` to provide configuration functionality. | ||
/// | ||
/// **Note**: Due to Swift limitations with static methods in protocol extensions, static functions | ||
/// in this extension should be called using `CustomerIOSdkClient.` to ensure correct behavior. | ||
extension SdkClient { | ||
|
||
/// Configures and overrides the shared `SdkClient` instance with provided parameters. | ||
/// | ||
/// - Parameter args: Dictionary containing values required for `SdkClient` protocol. | ||
/// - Returns: Configured `SdkClient` instance. Returns the existing shared client if required parameters are missing. | ||
@available(iOSApplicationExtension, unavailable) | ||
@discardableResult | ||
static func configure(using args: [String: Any?]) -> SdkClient { | ||
guard let source = args["source"] as? String, | ||
let version = args["version"] as? String | ||
else { | ||
DIGraphShared.shared.logger.error("Missing required parameters for SdkClient configuration in args: \(args)") | ||
return DIGraphShared.shared.sdkClient | ||
} | ||
|
||
let client = CustomerIOSdkClient(source: source, sdkVersion: version) | ||
DIGraphShared.shared.override(value: client, forType: SdkClient.self) | ||
|
||
return DIGraphShared.shared.sdkClient | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters