tvOS applications use the Permutive iOS SDK. The same SDK that powers iOS applications fully supports tvOS 12.0 and later, providing identical APIs for tracking, identity management, and ad targeting.
Same SDK, Same APIs: The Permutive iOS SDK supports both iOS and tvOS with a unified codebase. All features documented in the iOS SDK are available on tvOS unless otherwise noted.
// When ad startslet adTracker = try? mediaTracker?.createAdTracker( durationMilliseconds: 30000, // 30 second ad adProperties: AdTracker.AdProperties( title: "Advertisement", campaignId: "campaign_123" ))try? adTracker?.play()// When ad completesadTracker?.stop()
// Get all cohortslet cohorts = Permutive.shared.cohorts// Get activations for a specific ad platformlet gamActivations = Permutive.shared.activations(forPlatform: "gam")
import GoogleMobileAds// bannerView is a GAMBannerView instance in your view controllerlet adRequest = GAMRequest()adRequest.customTargeting = Permutive.shared.googleCustomTargeting( adTargetable: mediaTracker)bannerView.load(adRequest)
tvOS uses focus-based navigation with the Siri Remote. Ensure your tracking implementation doesn’t interfere with focus handling.
Copy
Ask AI
override func didUpdateFocus( in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) { // Handle focus changes // Tracking works independently of focus}
No IDFA/ATT on tvOS
Unlike iOS, tvOS does not support IDFA or App Tracking Transparency. Use alternative identifiers:
User account IDs (hashed)
identifierForVendor for anonymous tracking
Custom identifiers from your authentication system
Copy
Ask AI
// Use vendor identifierif let vendorId = UIDevice.current.identifierForVendor?.uuidString { try? Permutive.shared.setIdentities(aliases: [ Alias(tag: "vendor_id", identity: vendorId) ])}
Background Playback
tvOS apps may continue video playback in the background. Ensure your MediaTracker handles this:
Copy
Ask AI
NotificationCenter.default.addObserver( self, selector: #selector(appDidEnterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)@objc func appDidEnterBackground() { // Continue tracking if video plays in background // Or pause if playback stops if !player.isPlaying { mediaTracker?.pause() }}
Top Shelf Extensions
If your app has a Top Shelf extension, note that extensions run in a separate process and cannot share the Permutive SDK state with your main app.