iOS SDK
The Metica Ads SDK for iOS provides a simple, efficient way to integrate Metica's advertising functionality into your iOS applications. The SDK supports interstitial, rewarded, banner, and MREC ad formats with built-in A/B testing capabilities through Smart Floors.
Requirements
iOS 15.0 or higher
Swift 5.0+
Xcode 16.2+
AppLovinSDK dependency (version 13.0.0 or higher)
Valid Metica API credentials (API key, App ID)
CRITICAL REQUIREMENT
You must initialize the Metica SDK before invoking any ad methods. The Metica SDK handles AppLovin SDK initialization internally, so you should NOT initialize AppLovin SDK separately.
Callback Interfaces
MeticaInitCallback
Callback interface for SDK initialization events.
public protocol MeticaInitCallback {
func onInit(initResponse: MeticaInitResponse)
}onInit(initResponse:)
Called when the SDK has been initialized
MeticaAdsLoadCallback
Callback interface for ad loading events.
onAdLoadSuccess(meticaAd:)
Called when an ad has been successfully loaded
onAdLoadFailed(meticaAdError:)
Called when an ad load has failed
MeticaAdsShowCallback
Callback interface for ad display events.
onAdShowSuccess(meticaAd:)
Called when an ad has been shown successfully
onAdShowFailed(meticaAd:meticaAdError:)
Called when an ad failed to show
onAdHidden(meticaAd:)
Called when an ad has been dismissed
onAdClicked(meticaAd:)
Called when the user clicks an ad
onAdRevenuePaid(meticaAd:)
Called when revenue has been attributed
onAdRewarded(meticaAd:)
Called when a reward is earned (rewarded ads only)
MeticaAdsBannerCallback
Callback interface for banner/MREC ad events. Extends MeticaAdsLoadCallback.
Privacy Settings
Set privacy settings before calling MeticaSdk.initialize():
Ad Formats
Interstitial
.INTER
Full-screen ads that cover the interface
Rewarded
.REWARDED
Video ads that reward users for watching
Banner
.BANNER
Adaptive banner ads (320x50)
MREC
.MREC
Medium rectangle ads (300x250)
Code Examples
SDK Initialization
Interstitial Ads
Rewarded Ads
Banner/MREC Ads
Best Practices
Initialize on Main Thread: Always call
MeticaSdk.initialize()from the main thread using@MainActor.Set Privacy Settings First: Configure privacy settings before calling
initialize()to ensure proper propagation to ad networks.Enable Debug Logging: During development, enable logging for easier debugging:
Check Ad Readiness: Always verify ads are ready before showing:
Clean Up Banner/MREC Views: Call
destroy()on banner and MREC ad views when they're no longer needed to free resources.Handle All Callbacks: Implement both success and failure callbacks to handle all scenarios gracefully.
Thread Safety: All SDK methods are thread-safe. Callbacks are delivered on the main thread for UI updates.
Smart Floors / User Groups
The SDK uses Smart Floors for A/B testing optimization. After initialization, users are assigned to one of two groups:
trial
true
Metica optimization is enabled for this user
holdout
true
User is in the control group (no optimization)
holdout
false
Initialization failed; user defaults to holdout as fallback
Access the user's group after initialization:
Last updated
Was this helpful?

