Quick Start
Get started with the Ascend iOS SDK in just a few steps.
Initialize the SDK
Section titled “Initialize the SDK”import SwiftUIimport Ascend
@mainstruct MyApp: App { init() { setupAscendSDK() }
var body: some Scene { WindowGroup { ContentView() } }
private func setupAscendSDK() { // 1. Configure Core Settings let coreConfig = AscendCoreConfig( apiKey: "your-api-key", environment: "development", enableDebugLogging: true )
// 2. Configure HTTP Settings let httpConfig = HTTPConfig( apiBaseUrl: "https://api.ascend.com", timeout: 30.0, shouldRetry: true, maxRetries: 3, defaultHeaders: ["api-key": "your-api-key"] )
// 3. Configure Experiments Plugin let experimentsConfig = AscendExperimentsConfiguration.development( apiBaseUrl: "https://api.ascend.com", apiEndpoint: "/v1/allocations", defaultValues: [ "button_color": .dictionary([ "color": .string("blue") ]) ], headers: ["api-key": "your-api-key"] )
// 4. Create SDK Configuration let config = AscendConfig( plugins: [AscendPlugin(type: .experiments, config: experimentsConfig)], httpConfig: httpConfig, coreConfig: coreConfig )
// 5. Initialize the SDK do { try Ascend.initialize(with: config) print("✅ Ascend SDK initialized successfully")
// Set a user (required for experiments) Ascend.user.setUser(userId: "user-123") } catch { print("❌ Failed to initialize Ascend SDK: \(error)") } }}Use Experiments
Section titled “Use Experiments”// Get the experiments pluginlet experiments = try Ascend.getPlugin(AscendExperiments.self)
// Get string valuelet buttonColor = experiments.getStringValue(for: "button_color", with: "color")print("Button color: \(buttonColor)")
// Get boolean valuelet isEnabled = experiments.getBoolValue(for: "feature_toggle", with: "enabled")print("Feature enabled: \(isEnabled)")
// Get integer valuelet maxRetries = experiments.getIntValue(for: "retry_config", with: "max_attempts")print("Max retries: \(maxRetries)")Fetch Experiments from API
Section titled “Fetch Experiments from API”let experiments = try Ascend.getPlugin(AscendExperiments.self)
experiments.fetchExperiments(for: [ "button_color": .dictionary([ "color": .string("blue") ])]) { response, error in if let error = error { print("Error: \(error)") } else if let response = response { print("Fetched \(response.data?.count ?? 0) experiments") }}Use Events
Section titled “Use Events”Coming soon…