apple-wholeiOS 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 14+

  • AppLovinSDK dependency (version 13.0.0 or higher)

  • Valid Metica API credentials (API key, App ID)

circle-exclamation


Callback Interfaces

MeticaInitCallback

Callback interface for SDK initialization events.

public protocol MeticaInitCallback {
    func onInit(initResponse: MeticaInitResponse)
}
Method
Description

onInit(initResponse:)

Called when the SDK has been initialized

MeticaAdsLoadCallback

Callback interface for ad loading events.

Method
Description

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.

Method
Description

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

Format
Enum Value
Description

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


Best Practices

  1. Initialize on Main Thread: Always call MeticaSdk.initialize() from the main thread using @MainActor.

  2. Set Privacy Settings First: Configure privacy settings before calling initialize() to ensure proper propagation to ad networks.

  3. Enable Debug Logging: During development, enable logging for easier debugging:

  4. Check Ad Readiness: Always verify ads are ready before showing:

  5. Clean Up Banner/MREC Views: Call destroy() on banner and MREC ad views when they're no longer needed to free resources.

  6. Handle All Callbacks: Implement both success and failure callbacks to handle all scenarios gracefully.

  7. 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:

User Group
isSuccess
Description

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?