iOS Integration Guide
SDK version: 1.0.0Platform: iOS (Swift / SwiftUI)
Min deployment target: iOS 16.0
Build system: Xcode 15+ / Swift Package Manager Get your API key from app.revrag.ai → Settings → API Keys.
Table of Contents
- Requirements
- How it works
- Step 1 — Add the package
- Step 2 — Add microphone permission
- Step 3 — Initialize the SDK
- Step 4 — Identify the user
- Step 5 — Add the floating button
- Routing scenarios
- Button visibility control
- Events
- Analytics helpers
- Cleanup on logout
- Configuration reference
- Troubleshooting
- Pre-ship checklist
1. Requirements
Step 1 — Add the package
Swift Package Manager (recommended)
In Xcode: File → Add Package Dependencies Paste the URL:Up to Next Major Version from 1.0.0 → select RevragEmbed → click Add Package.
CocoaPods alternative
Step 2 — Add microphone permission
Add toInfo.plist:
+ button → Privacy - Microphone Usage Description → enter a description.
Step 3 — Initialize the SDK
CallEmbedSDK.shared.initialize() once, as early as possible.
SwiftUI App entry point
UIKit AppDelegate
Step 4 — Identify the user
Call this right after your login flow completes:Step 5 — Add the floating button
Apply the.embedProvider() modifier to your root view. This overlays the draggable button on top of all your existing content.
UIKit alternative
AddEmbedButton as an overlay view in your root UIViewController:
.embedProvider() modifier props
Routing scenarios
Screen tracking lets the agent know which screen the user is on. Choose the scenario that matches your navigation setup.Scenario A — NavigationStack (most common)
PostEmbedViewDidAppear from .onAppear on each screen. The SDK listens for this notification and updates the current screen name.
Scenario B — TabView with multiple stacks
Apply.embedProvider() outside the TabView so the button floats above all tabs. Each tab’s screens post EmbedViewDidAppear from .onAppear as shown in Scenario A.
Scenario C — No NavigationStack (flat views / custom transitions)
Fire the notification manually when your view becomes visible. You can also postEmbedViewDidDisappear on exit.
Scenario D — UIKit UINavigationController
Pass theUINavigationController to .embedProvider() for automatic tracking:
UINavigationControllerDelegate and fires SCREEN_STATE events automatically — no .onAppear notifications needed.
Button visibility control
By default the button shows on every screen. UseEmbedButtonVisibilityConfig to control this.
Show only on specific screens
Keep button visible across a flow (e.g. checkout)
Use a group with.continuous continuity so the button doesn’t flash between screens:
Visibility rules (evaluated in priority order)
Events
EventKeys reference
Sending events
Listen for agent call events
Agent lifecycle events reference
Analytics helpers
These helpers fireanalyticsData events with standardized payloads.
Events auto-fired by the SDK
Cleanup on logout
Call this when the user logs out or switches accounts to prevent stale data from leaking into the next session.Configuration reference
EmbedButtonVisibilityConfig
EmbedButtonGroupConfig
EmbedButtonDelayPolicy
EmbedButton direct props
Troubleshooting
App crashes on first call
Error:NSMicrophoneUsageDescription to Info.plist. See Step 2 above.
The button never appears
Cause A —initialize() not called or failed
Check the Xcode console for [RevragEmbed] prefixed logs:
Cause B — SDK not ready yet
initialize() is async. The button is hidden until isInitialized = true and appears automatically — no action required. To observe readiness:
Cause C — Screen excluded by visibility config Screen names are case-sensitive and must match exactly what you post in
EmbedViewDidAppear notifications.
Button disappears when switching tabs
Cause:.embedProvider() is applied inside a tab instead of outside the TabView.
Screen tracking not working (agent doesn’t know current screen)
Cause:EmbedViewDidAppear notification not posted from .onAppear.
Background music doesn’t resume after a call
The SDK callsAVAudioSession.setActive(false, options: .notifyOthersOnDeactivation) automatically in endCall(). If you observe this issue, ensure you are on SDK version ≥ 1.0 and that the session is not being deactivated before the SDK finishes cleaning up.
Analytics events missing from dashboard
Check in this order:USER_DATAwas sent with a validapp_user_idbefore other eventsinitialize()completed successfully (isInitialized == true)- Device has internet connectivity
- The SDK rate-limits to 5 req/s — bursts are queued, not dropped
User identity leaks between accounts
Always callclearStorageCache() on logout before the next user logs in:
Pre-ship checklist
Basic setup
- Package added via Xcode SPM:
https://github.com/RevRag-ai/embed-native -
NSMicrophoneUsageDescriptionadded toInfo.plist -
await EmbedSDK.shared.initialize(apiKey:)called inApp.init()orAppDelegate -
USER_DATAevent sent withapp_user_idimmediately after login -
.embedProvider()applied to the root view (outsideTabViewif tabs are used) -
clearStorageCache()called on logout
Screen tracking
-
EmbedViewDidAppearnotification posted from every screen’s.onAppear(SwiftUI NavigationStack) - Or
navigationControllerpassed to.embedProvider()for automatic UIKit tracking - Screen names in notifications match
visibilityConfigexactly (case-sensitive)
Visibility
-
visibilityConfigconfigured if the button should not show on all screens -
.embedProvider()placed outsideTabView(if applicable)
Production readiness
-
[RevragEmbed]logs checked — no initialization errors - Agent event listeners started and stopped at appropriate lifecycle points
- Tested on a physical device — microphone permission dialog does not appear in Simulator
Support
- Issues: GitHub Issues
- Docs: Revrag Documentation
- Dashboard: app.revrag.ai