Reachu SDK Configuration Guide
This comprehensive guide explains how to configure the Reachu Swift SDK to match your app's branding and requirements. Configure once and use everywhere - no repeated setup needed!
Quick Start
Option 1: Simple Setup (API Key Only)
import ReachuCore
// In your AppDelegate or App.swift
ReachuConfiguration.configure(apiKey: "your-api-key-here")
// Now use anywhere in your app without additional setup
RProductCard(product: product) // Automatically configured
RCheckoutOverlay() // Uses global settings
Option 2: Configuration File (Recommended)
**Step 1:**Copy configuration files from the demo app
**Step 2:**Add to your Xcode project
**Step 3:**Load in your app startup
import ReachuCore
// In your AppDelegate or App.swift
do {
// Auto-detect config file (reads environment variables)
try ConfigurationLoader.loadConfiguration()
} catch {
print("Failed to load configuration: \(error)")
// Fallback to basic configuration
ReachuConfiguration.configure(apiKey: "your-api-key")
}
Option 3: Environment Variables (Quick Theme Switching)
Set environment variables in your app for instant theme switching:
**In Xcode:**1. Edit Scheme → Run → Environment Variables
2. Add: REACHU_CONFIG_TYPE = dark-streaming (or automatic)
3. Run → SDK automatically uses the correct theme
Available themes: - dark-streaming - Dark theme for streaming apps
automatic- Follows iOS system themeexample- Default configuration
Configuration File Setup
Step 1: Download Template
Copy this complete configuration file to get started:
File Name:reachu-config.json
{
"apiKey": "YOUR_REACHU_API_KEY_HERE",
"environment": "production",
"theme": {
"name": "My Store Theme",
"colors": {
"primary": "#007AFF",
"secondary": "#5856D6"
}
},
"cart": {
"floatingCartPosition": "bottomRight",
"floatingCartDisplayMode": "full",
"floatingCartSize": "medium",
"autoSaveCart": true,
"showCartNotifications": true,
"enableGuestCheckout": true,
"requirePhoneNumber": true,
"defaultShippingCountry": "US",
"supportedPaymentMethods": ["stripe", "klarna", "paypal"]
},
"ui": {
"defaultProductCardVariant": "grid",
"enableProductCardAnimations": true,
"showProductBrands": true,
"showProductDescriptions": false,
"imageQuality": "medium",
"enableImageCaching": true,
"typography": {
"fontFamily": null,
"enableCustomFonts": false,
"supportDynamicType": true,
"lineHeightMultiplier": 1.2,
"letterSpacing": 0.0
},
"shadows": {
"cardShadowRadius": 4,
"cardShadowOpacity": 0.1,
"buttonShadowEnabled": true,
"enableBlurEffects": true,
"blurIntensity": 0.3
},
"animations": {
"defaultDuration": 0.3,
"springResponse": 0.4,
"springDamping": 0.8,
"enableSpringAnimations": true,
"enableMicroInteractions": true,
"respectReduceMotion": true,
"animationQuality": "high"
},
"layout": {
"gridColumns": 2,
"gridSpacing": 16,
"respectSafeAreas": true,
"enableResponsiveLayout": true,
"screenMargins": 16,
"sectionSpacing": 24
},
"accessibility": {
"enableVoiceOverOptimizations": true,
"enableDynamicTypeSupport": true,
"respectHighContrastMode": true,
"respectReduceMotion": true,
"minimumTouchTargetSize": 44,
"enableHapticFeedback": true,
"hapticIntensity": "medium"
},
"enableAnimations": true,
"animationDuration": 0.3,
"enableHapticFeedback": true
},
"network": {
"timeout": 30.0,
"retryAttempts": 3,
"enableCaching": true,
"cacheDuration": 300,
"enableQueryBatching": true,
"maxConcurrentRequests": 6,
"requestPriority": "normal",
"enableCompression": true,
"enableSSLPinning": false,
"enableCertificateValidation": true,
"enableLogging": false,
"logLevel": "info",
"enableNetworkInspector": false,
"enableOfflineMode": false,
"offlineCacheDuration": 86400,
"syncStrategy": "automatic"
},
"liveShow": {
"autoJoinChat": true,
"enableChatModeration": true,
"maxChatMessageLength": 200,
"enableEmojis": true,
"enableShoppingDuringStream": true,
"showProductOverlays": true,
"enableQuickBuy": true,
"enableStreamNotifications": true,
"enableProductNotifications": true,
"enableChatNotifications": false,
"videoQuality": "auto",
"enableAutoplay": false,
"enablePictureInPicture": true,
"campaignId": 0
},
"marketFallback": {
"countryCode": "US",
"countryName": "United States",
"currencyCode": "USD",
"currencySymbol": "$",
"phoneCode": "+1",
"flag": "https://flagcdn.com/w40/us.png"
},
"localization": {
"defaultLanguage": "en",
"fallbackLanguage": "en",
"translationsFile": "reachu-translations"
},
"analytics": {
"enabled": true,
"mixpanelToken": "your-mixpanel-project-token",
"apiHost": "https://api-eu.mixpanel.com",
"trackComponentViews": true,
"trackComponentClicks": true,
"trackImpressions": true,
"trackTransactions": true,
"trackProductEvents": true,
"autocapture": false,
"recordSessionsPercent": 0
}
}
**Important:**Analytics tracking requires a Mixpanel token. If mixpanelToken is not provided, no events will be tracked. See the Analytics Configuration section below for details.
Step 2: Add to Xcode Project
- Create the file: - Right-click your project in Xcode
- Select "New File" → "Other" → "Empty"
- Name it
reachu-config.json
- Add to bundle: - Make sure "Add to target" is checked for your main app target
- The file should appear in your project navigator
- Verify bundle inclusion: - Select your project → Build Phases → Copy Bundle Resources
- Ensure
reachu-config.jsonis listed
Step 3: Load Configuration
Add this code to your app startup (AppDelegate.swift or App.swift):
import ReachuCore
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Load Reachu configuration
do {
try ConfigurationLoader.loadFromJSON(fileName: "reachu-config")
print(" Reachu SDK configured successfully")
} catch {
print(" Failed to load Reachu configuration: \(error)")
// Fallback to basic configuration
ReachuConfiguration.configure(apiKey: "YOUR_API_KEY_HERE")
}
return true
}
}
For SwiftUI Apps (App.swift):
import SwiftUI
import ReachuCore
@main
struct MyApp: App {
init() {
configureReachu()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
private func configureReachu() {
do {
try ConfigurationLoader.loadFromJSON(fileName: "reachu-config")
print(" Reachu SDK configured successfully")
} catch {
print(" Failed to load Reachu configuration: \(error)")
ReachuConfiguration.configure(apiKey: "YOUR_API_KEY_HERE")
}
}
}
Configuration Sections Explained
API & Environment
{
"apiKey": "YOUR_REACHU_API_KEY_HERE", // REQUIRED: Your Reachu API key
"environment": "production" // production | sandbox
}
**Effect:**Determines which Reachu servers to connect to and authenticates your app.
Theme & Colors
Automatic Dark/Light Mode Support (Recommended)
{
"theme": {
"name": "My Store Theme",
"mode": "automatic", // automatic | light | dark
"lightColors": {
"primary": "#007AFF", // Light mode brand color
"secondary": "#5856D6" // Light mode accent color
},
"darkColors": {
"primary": "#0A84FF", // Dark mode brand color (brighter)
"secondary": "#5E5CE6" // Dark mode accent color (brighter)
}
}
}
Single Theme Mode (Legacy)
{
"theme": {
"name": "My Store Theme",
"mode": "light", // Force light mode
"colors": {
"primary": "#007AFF", // Main brand color
"secondary": "#5856D6" // Secondary brand color
}
}
}
Theme Mode Options:
automatic- Automatically adapts to system light/dark modelight- Forces light theme regardless of system settingdark- Forces dark theme regardless of system setting
**Effect:**All Reachu UI components automatically adapt to light/dark modes. Colors, backgrounds, and text contrast adjust seamlessly based on the user's system preferences or your override setting.
Shopping Cart
{
"cart": {
"floatingCartPosition": "bottomRight", // Where cart appears on screen
"floatingCartDisplayMode": "full", // How much info to show
"floatingCartSize": "medium", // Size of floating cart
"autoSaveCart": true, // Save cart between app sessions
"showCartNotifications": true, // Show "Added to cart" messages
"enableGuestCheckout": true, // Allow checkout without account
"requirePhoneNumber": true, // Require phone in checkout
"defaultShippingCountry": "US", // Default country for shipping
"supportedPaymentMethods": ["stripe", "klarna", "paypal"] // Available payment options
}
}
**Effect:**Controls how users interact with the shopping cart throughout your app.
Cart Position Options:
topLeft topCenter topRight
centerLeft centerRight
bottomLeft bottomCenter bottomRight
Display Mode Options:
full- Shows cart icon, item count, and total pricecompact- Shows cart icon and item count onlyminimal- Shows cart icon with small badgeiconOnly- Shows only the cart icon
UI Components
{
"ui": {
"defaultProductCardVariant": "grid", // Default product card style
"enableProductCardAnimations": true, // Enable card animations
"showProductBrands": true, // Show brand names on products
"showProductDescriptions": false, // Show product descriptions
"imageQuality": "medium", // Image quality (low/medium/high)
"enableImageCaching": true, // Cache images for performance
"typography": {
"fontFamily": null, // Custom font family (null = system)
"enableCustomFonts": false, // Enable custom font loading
"supportDynamicType": true, // Support iOS Dynamic Type
"lineHeightMultiplier": 1.2, // Line height multiplier
"letterSpacing": 0.0 // Letter spacing adjustment
},
"shadows": {
"cardShadowRadius": 4, // Shadow blur radius for cards
"cardShadowOpacity": 0.1, // Shadow opacity (0.0 - 1.0)
"buttonShadowEnabled": true, // Enable shadows on buttons
"enableBlurEffects": true, // Enable blur effects
"blurIntensity": 0.3 // Blur intensity (0.0 - 1.0)
},
"animations": {
"defaultDuration": 0.3, // Default animation duration (seconds)
"springResponse": 0.4, // Spring animation response
"springDamping": 0.8, // Spring animation damping
"enableSpringAnimations": true, // Use spring animations
"enableMicroInteractions": true, // Small interaction animations
"respectReduceMotion": true, // Respect accessibility settings
"animationQuality": "high" // Animation quality (low/medium/high)
},
"layout": {
"gridColumns": 2, // Columns in product grids
"gridSpacing": 16, // Space between grid items
"respectSafeAreas": true, // Respect device safe areas
"enableResponsiveLayout": true, // Adapt to screen sizes
"screenMargins": 16, // Screen edge margins
"sectionSpacing": 24 // Space between sections
},
"accessibility": {
"enableVoiceOverOptimizations": true, // Optimize for VoiceOver
"enableDynamicTypeSupport": true, // Support Dynamic Type
"respectHighContrastMode": true, // Respect high contrast mode
"respectReduceMotion": true, // Respect reduce motion
"minimumTouchTargetSize": 44, // Minimum touch target size
"enableHapticFeedback": true, // Enable haptic feedback
"hapticIntensity": "medium" // Haptic intensity (light/medium/heavy)
}
}
}
**Effect:**Controls the look, feel, and behavior of all UI components in the SDK.
Network & Performance
{
"network": {
"timeout": 30.0, // Request timeout (seconds)
"retryAttempts": 3, // Number of retry attempts
"enableCaching": true, // Enable response caching
"cacheDuration": 300, // Cache duration (seconds)
"enableQueryBatching": true, // Batch GraphQL queries
"maxConcurrentRequests": 6, // Max concurrent requests
"requestPriority": "normal", // Request priority (low/normal/high)
"enableCompression": true, // Enable request compression
"enableSSLPinning": false, // Enable SSL certificate pinning
"enableCertificateValidation": true, // Validate SSL certificates
"enableLogging": false, // Enable network logging
"logLevel": "info", // Log level (debug/info/warning/error)
"enableNetworkInspector": false, // Enable network debugging
"enableOfflineMode": false, // Enable offline functionality
"offlineCacheDuration": 86400, // Offline cache duration (seconds)
"syncStrategy": "automatic" // Sync strategy (manual/automatic)
}
}
**Effect:**Optimizes network performance and handles connectivity issues.
LiveShow Features
The SDK now supports comprehensive LiveShow configurations with Tipio.no integration:
{
"liveShow": {
"tipio": {
"apiKey": "your-tipio-api-key-here",
"baseUrl": "https://api.tipio.no",
"enableWebhooks": true,
"webhookSecret": "your-webhook-secret"
},
"vimeo": {
"apiKey": "your-vimeo-api-key",
"accessToken": "your-vimeo-access-token",
"baseUrl": "https://api.vimeo.com",
"enableEmbedPlayer": true
},
"realTime": {
"webSocketUrl": "wss://ws.reachu.com",
"autoReconnect": true,
"heartbeatInterval": 30,
"maxReconnectAttempts": 5,
"componentCacheTimeout": 300,
"autoRefreshInterval": 60
},
"components": {
"enableDynamicComponents": true,
"maxConcurrentComponents": 5,
"defaultAnimationDuration": 0.3,
"enableOfflineCache": true,
"preloadNextComponents": true
},
"streaming": {
"autoJoinChat": true, // Auto-join chat when viewing
"enableAutoplay": false, // Auto-play live streams
"videoQuality": "auto", // Video quality (auto/low/medium/high)
"enablePictureInPicture": true, // Picture-in-picture support
"enableFullscreen": true, // Fullscreen video support
"showStreamControls": false, // Show video controls
"muteByDefault": true // Start videos muted
},
"chat": {
"enableChat": true, // Enable live chat
"enableChatModeration": true, // Enable chat moderation
"maxChatMessageLength": 200, // Max characters per message
"enableEmojis": true, // Allow emoji reactions
"enableChatNotifications": false, // Chat message notifications
"chatRefreshInterval": 2.0, // Chat refresh rate (seconds)
"enableUserMentions": true, // Allow @mentions
"enableChatHistory": true, // Store chat history
"showChatAvatars": true // Show user avatars
},
"shopping": {
"enableShoppingDuringStream": true, // Allow shopping during stream
"showProductOverlays": true, // Show product overlays
"enableQuickBuy": true, // Enable quick buy buttons
"productOverlayDuration": 10.0, // Overlay display time (seconds)
"enableProductNotifications": true, // Product-related notifications
"integrateLiveCart": true, // Integrate with main cart
"specialPricingEnabled": true, // Enable special live pricing
"countdownEnabled": true // Enable countdown timers
},
"ui": {
"playerAspectRatio": "16:9", // Video player aspect ratio
"enableLiveIndicator": true, // Show "LIVE" indicator
"showViewerCount": false, // Show viewer count
"enableShareButton": true, // Enable share functionality
"layout": {
"defaultLayout": "fullScreenOverlay", // Default layout mode
"enableLayoutSwitching": true, // Allow layout switching
"miniPlayerPosition": "bottomRight" // Mini player position
},
"branding": {
"liveIndicatorColor": "#FF3B30", // Live indicator color
"accentColor": "#0066FF", // Accent color
"overlayBackgroundOpacity": 0.90, // Background overlay opacity
"gradientOverlay": true, // Enable gradient overlays
"cardBackgroundColor": "#0D0D0F", // Card background color
"highlightColor": "#00A8FF", // Highlight color
"shadowColor": "#000000", // Shadow color
"shadowOpacity": 0.5 // Shadow opacity
},
"animations": {
"enableEntryAnimations": true, // Component entry animations
"enableExitAnimations": true, // Component exit animations
"componentTransitionDuration": 0.4, // Transition duration
"fadeInDuration": 0.6, // Fade in duration
"slideAnimationEnabled": true // Enable slide animations
}
},
"notifications": {
"enableStreamNotifications": true, // Stream event notifications
"enableProductNotifications": true, // Product-related notifications
"enableComponentNotifications": true, // Dynamic component notifications
"notificationSound": true, // Enable notification sounds
"showNotificationBadges": true // Show notification badges
}
}
}
**Effect:**Controls comprehensive livestream functionality including Tipio.no integration, real-time components, chat, shopping, and dynamic UI elements during live shows.
When campaignId is set to a value greater than 0, the SDK will:
- Connect to WebSocket for real-time campaign events
- Respect campaign start/end dates
- Hide components when campaign is not active
See Campaign Lifecycle Guide for complete details.
Market Fallback Configuration
Configure fallback market data when API is unavailable:
{
"marketFallback": {
"countryCode": "US",
"countryName": "United States",
"currencyCode": "USD",
"currencySymbol": "$",
"phoneCode": "+1",
"flag": "https://flagcdn.com/w40/us.png"
}
}
When Used: - When market API is unavailable (404 errors)
- During network failures
- As default values for cart and checkout
Effect: Provides default market data so the app continues to function even if API calls fail.
You can also enable automatic market detection by passing userCountryCode to ConfigurationLoader.loadConfiguration().
See Market Availability Guide for complete details.
Localization Configuration
Configure multi-language support for the SDK:
{
"localization": {
"defaultLanguage": "en",
"fallbackLanguage": "en",
"translationsFile": "reachu-translations"
}
}
Key Properties: - defaultLanguage: Default language code (e.g., "en", "es", "no")
fallbackLanguage: Fallback language if translation missing (default: "en")translationsFile: Name of external translation file without .json extension
Option 1: Separate Translation File (Recommended)
{
"localization": {
"defaultLanguage": "es",
"fallbackLanguage": "en",
"translationsFile": "reachu-translations"
}
}
Option 2: Inline Translations
{
"localization": {
"defaultLanguage": "es",
"fallbackLanguage": "en",
"translations": {
"en": {
"cart.title": "Cart",
"checkout.title": "Checkout"
},
"es": {
"cart.title": "Carrito",
"checkout.title": "Checkout"
}
}
}
}
The SDK includes default English translations built-in. If no translation files are provided, components will display in English automatically.
See Localization Guide for complete details and all available translation keys.
Analytics Configuration
Configure analytics tracking using Mixpanel. Important: Analytics tracking will only work if you provide a Mixpanel token. Without it, no events will be tracked.
{
"analytics": {
"enabled": true,
"mixpanelToken": "your-mixpanel-project-token",
"apiHost": "https://api-eu.mixpanel.com",
"trackComponentViews": true,
"trackComponentClicks": true,
"trackImpressions": true,
"trackTransactions": true,
"trackProductEvents": true,
"autocapture": false,
"recordSessionsPercent": 0
}
}
Key Properties: - enabled: Enable/disable analytics tracking (default: false)
mixpanelToken: REQUIRED - Your Mixpanel project token. If not provided, no events will be tracked. -apiHost: Optional Mixpanel API host (default: US region). Use"https://api-eu.mixpanel.com"for EU region.trackComponentViews: Track when components are viewed (default:true)trackComponentClicks: Track component interactions/clicks (default:true)trackImpressions: Track component impression duration (default:true)trackTransactions: Track checkout and purchase events (default:true)trackProductEvents: Track product views and add-to-cart events (default:true)autocapture: Enable Mixpanel autocapture (default:false)recordSessionsPercent: Percentage of sessions to record (0-100, default:0)
**Important Notes:**1. Mixpanel Token Required: Analytics tracking is disabled by defaultand will not workunless you provide a valid mixpanelToken. Without the token, all tracking methods will silently fail.
-
Automatic Enable: If you provide a
mixpanelToken, analytics will be automatically enabled even ifenabledis set tofalse. -
Event Types Tracked:
- Component views (when UI components appear)
- Component clicks (user interactions)
- Component impressions (viewing duration)
- Product views and add-to-cart events
- Checkout started and completed events
- Transaction/purchase events
Example Configuration:
{
"analytics": {
"enabled": true,
"mixpanelToken": "d0e5d6e5ff24fea6e7a377f04e84aa99",
"apiHost": "https://api-eu.mixpanel.com",
"trackComponentViews": true,
"trackComponentClicks": true,
"trackImpressions": true,
"trackTransactions": true,
"trackProductEvents": true
}
}
**Getting Your Mixpanel Token:**1. Sign in to your Mixpanel account 2. Go to Project Settings → Project Info3. Copy your Project Token4. Add it to your configuration file
**Effect:**All SDK components automatically track user interactions and events to Mixpanel when a valid token is provided. If no token is provided, tracking is completely disabled and no events are sent.
Updating Configuration
Method 1: Edit the JSON File
- Open
reachu-config.jsonin Xcode - Modify the values you want to change
- Save the file
- Restart your app to see changes