Skip to main content

Core Classes

CloudXCore

Main SDK singleton class. Framework: CloudXCore

Initialization

CloudXCore.shared.initializeSDK(withAppKey: String, completion: ((Bool, Error?) -> Void)?)
CloudXCore.shared.initializeSDK(withAppKey: String, hashedUserID: String, completion: ((Bool, Error?) -> Void)?)

Properties

var isInitialized: Bool { get }
var sdkVersion: String { get }

Ad Creation

func createBanner(withPlacement: String, viewController: UIViewController, delegate: CLXBannerDelegate?, tmax: Int) -> CLXBannerAdView
func createMREC(withPlacement: String, viewController: UIViewController, delegate: CLXBannerDelegate?) -> CLXBannerAdView
func createInterstitial(withPlacement: String, delegate: CLXInterstitialDelegate?) -> CLXInterstitial
func createRewarded(withPlacement: String, delegate: CLXRewardedDelegate?) -> CLXRewarded
func createNativeAd(withPlacement: String, viewController: UIViewController, delegate: CLXNativeDelegate?) -> CLXNativeAdView

Privacy Settings

CloudXCore.setIsUserConsent(Bool)
CloudXCore.setIsAgeRestrictedUser(Bool)
CloudXCore.setIsDoNotSell(Bool)
CloudXCore.setCCPAPrivacyString(String)

Targeting

CloudXCore.shared.setHashedUserID(String)
CloudXCore.shared.setHashedKeyValue(String, value: String)
CloudXCore.shared.setKeyValueDictionary([String: String])
CloudXCore.shared.setUserKeyValue(String, value: String)
CloudXCore.shared.setAppKeyValue(String, value: String)
CloudXCore.shared.setBidderKeyValue(String, key: String, value: String)
CloudXCore.shared.clearAllKeyValues()

Logging

CloudXCore.setLoggingEnabled(Bool)
CloudXCore.setMinLogLevel(CLXLogLevel)
CloudXCore.setLoggingEmojisEnabled(Bool)

Ad Classes

CLXBannerAdView

Banner and MREC ad view (extends UIView). Methods:
func load()
func startAutoRefresh()
func stopAutoRefresh()
func destroy()
var delegate: CLXBannerDelegate? { get set }

CLXInterstitial

Fullscreen interstitial ad. Methods:
func load()
func show(from viewController: UIViewController)
func destroy()
var isReady: Bool { get }
var delegate: CLXInterstitialDelegate? { get set }

CLXRewarded

Fullscreen rewarded video ad. Methods:
func load()
func show(from viewController: UIViewController)
func destroy()
var isReady: Bool { get }
var delegate: CLXRewardedDelegate? { get set }

CLXNativeAdView

Native ad view (extends UIView). Methods:
func load()
func destroy()
var delegate: CLXNativeDelegate? { get set }

Delegate Protocols

CLXAdDelegate

Base ad event protocol.
@objc protocol CLXAdDelegate {
    func didLoad(with ad: CLXAd)
    func failToLoad(with ad: CLXAd, error: Error)
    func didShow(with ad: CLXAd)
    func failToShow(with ad: CLXAd, error: Error)
    func didHide(with ad: CLXAd)
    func didClick(with ad: CLXAd)
    func impressionOn(_ ad: CLXAd)
    func revenuePaid(_ ad: CLXAd)
}

CLXBannerDelegate

Banner and MREC delegate (extends CLXAdDelegate).
@objc protocol CLXBannerDelegate : CLXAdDelegate {
    @objc optional func didExpandAd(_ ad: CLXAd)
    @objc optional func didCollapseAd(_ ad: CLXAd)
}

CLXInterstitialDelegate

Interstitial delegate (extends CLXAdDelegate).
@objc protocol CLXInterstitialDelegate : CLXAdDelegate {
}

CLXRewardedDelegate

Rewarded ad delegate (extends CLXAdDelegate).
@objc protocol CLXRewardedDelegate : CLXAdDelegate {
    func userRewarded(_ ad: CLXAd)
}

CLXNativeDelegate

Native ad delegate (extends CLXAdDelegate).
@objc protocol CLXNativeDelegate : CLXAdDelegate {
}

Model Classes

CLXAd

Ad metadata.
@objc protocol CLXAd {
    var placementName: String { get }
    var placementId: String { get }
    var bidder: String { get }
    var externalPlacementId: String { get }
    var revenue: NSNumber { get }
}

Enums

CLXErrorCode

@objc enum CLXErrorCode: Int {
    // Initialization (100-199)
    case notInitialized = 100
    case initializationInProgress = 101
    case noAdaptersFound = 102
    case initializationTimeout = 103
    case invalidAppKey = 104
    case sdkDisabled = 105

    // Network (200-299)
    case networkError = 200
    case networkTimeout = 201
    case invalidResponse = 202
    case serverError = 203

    // Ad Loading (300-399)
    case noFill = 300
    case invalidRequest = 301
    case invalidPlacement = 302
    case loadTimeout = 303
    case loadFailed = 304
    case invalidAd = 305
    case tooManyRequests = 306
    case requestCancelled = 307
    case adsDisabled = 308

    // Ad Display (400-499)
    case adNotReady = 400
    case adAlreadyShown = 401
    case adExpired = 402
    case invalidViewController = 403
    case showFailed = 404

    // Configuration (500-599)
    case invalidAdUnit = 500
    case permissionDenied = 501
    case unsupportedAdFormat = 502
    case invalidBannerView = 503
    case invalidNativeView = 504
}

CLXLogLevel

@objc enum CLXLogLevel: Int {
    case verbose = 0
    case debug = 1
    case info = 2
    case warn = 3
    case error = 4
}

Installation

CocoaPods

pod 'CloudXCore'
pod 'CloudXMetaAdapter'
pod 'CloudXVungleAdapter'

Swift Package Manager

https://github.com/cloudx-io/cloudx-ios
Current Version: 1.1.57 Min iOS: 14.0 Xcode: 12.0+