Skip to main content

Getting started - iOS and tvOS

The OptSens SDK is a Swift package. Add it, call OptSens.configure with your SDK ID, and present the banner. The same package runs on iPhone, iPad and Apple TV.

Requirements

  • The SDK is available on the Pro, Business and Custom plans.
  • iOS 16 or higher, tvOS 17 or higher.
  • Swift Package Manager. The SDK never shows the App Tracking Transparency prompt; your app makes that prompt if it needs one.

Get your SDK ID

  1. In your OptSens dashboard, click Add Domain in the top navigation and add this app. See Add your app for the full flow (choosing the platform, entering the app id, picking a plan).
  2. Run the guided onboarding. On the Integration step, copy your SDK ID. It is also on the dashboard Integration page at any time.

Add the SDK

In Xcode, choose File > Add Package Dependencies, enter the repository URL, and add the OptSensUI product to your app target. It pulls the consent engine in for you. Or add it in Package.swift:

dependencies: [
.package(url: "https://github.com/Optsens/optsens-sdk-ios.git", from: "1.0.0")
]

Initialize OptSens and show the banner

Call OptSens.configure once on launch with your SDK ID. When consent is needed, present the OptSensBanner view over your UI as a sheet or full-screen overlay:

import OptSensCore
import OptSensUI

OptSens.configure(apiKey: "YOUR_SDK_ID") { result in
if case .success(let status) = result, status.shouldCollectConsent,
let config = OptSens.config() {
OptSensBanner(
config: config,
language: OptSens.bannerLanguage(),
iabActive: OptSens.isIabActive(),
onAccept: { OptSens.acceptAll() },
onReject: { OptSens.rejectAll() },
onSave: { decision, acIds, categories in
OptSens.saveDecision(decision, acConsentedIds: acIds, meta: DecisionMeta(categories: categories))
}
)
}
}

configure fetches your banner configuration, resolves the visitor's region and device language, and writes the on-device consent keys. For a US privacy visitor, show the "Your Privacy Choices" panel instead with OptSens.applyUsPrivacy.

To let visitors reopen their choice later, add the floating button as an overlay in your main view. Unlike the web, where the button is injected for you, in an app you place it yourself, once. See Floating button.

Apple TV

The same package runs on Apple TV (tvOS 17). The banner switches to the large-screen layout with remote focus on its own. Re-consent on TV uses a view you place in your own menu. See Connected TV.

After integrating

  1. Run the app. The banner shows on first launch when consent is needed.
  2. Confirm the integration from the app's Verify step in the dashboard.
  3. Gate your own analytics and ad code with OptSens.hasConsent, and set up consent forwarding for Google and your attribution partners.

Next: Showing the banner.