跳转到主要内容

核心类

CloudXCore

主 SDK 单例类。 框架: CloudXCore

初始化

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

属性

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

广告创建

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

隐私设置

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

定向

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()

日志

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

广告类

CLXBannerAdView

横幅和 MREC 广告视图(扩展 UIView)。 方法:
func load()
func startAutoRefresh()
func stopAutoRefresh()
func destroy()
var delegate: CLXBannerDelegate? { get set }

CLXInterstitial

全屏插屏广告。 方法:
func load()
func show(from viewController: UIViewController)
func destroy()
var isReady: Bool { get }
var delegate: CLXInterstitialDelegate? { get set }

CLXRewarded

全屏激励视频广告。 方法:
func load()
func show(from viewController: UIViewController)
func destroy()
var isReady: Bool { get }
var delegate: CLXRewardedDelegate? { get set }

CLXNativeAdView

原生广告视图(扩展 UIView)。 方法:
func load()
func destroy()
var delegate: CLXNativeDelegate? { get set }

代理协议

CLXAdDelegate

基础广告事件协议。
@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

横幅和 MREC 代理(扩展 CLXAdDelegate)。
@objc protocol CLXBannerDelegate : CLXAdDelegate {
    @objc optional func didExpandAd(_ ad: CLXAd)
    @objc optional func didCollapseAd(_ ad: CLXAd)
}

CLXInterstitialDelegate

插屏代理(扩展 CLXAdDelegate)。
@objc protocol CLXInterstitialDelegate : CLXAdDelegate {
}

CLXRewardedDelegate

激励广告代理(扩展 CLXAdDelegate)。
@objc protocol CLXRewardedDelegate : CLXAdDelegate {
    func userRewarded(_ ad: CLXAd)
}

CLXNativeDelegate

原生广告代理(扩展 CLXAdDelegate)。
@objc protocol CLXNativeDelegate : CLXAdDelegate {
}

模型类

CLXAd

广告元数据。
@objc protocol CLXAd {
    var placementName: String { get }
    var placementId: String { get }
    var bidder: String { get }
    var externalPlacementId: String { get }
    var revenue: NSNumber { get }
}

枚举

CLXErrorCode

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

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

    // 广告加载 (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

    // 广告展示 (400-499)
    case adNotReady = 400
    case adAlreadyShown = 401
    case adExpired = 402
    case invalidViewController = 403
    case showFailed = 404

    // 配置 (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
}

安装

CocoaPods

pod 'CloudXCore'
pod 'CloudXMetaAdapter'
pod 'CloudXVungleAdapter'
当前版本: 1.1.57 最低 iOS: 14.0 Xcode: 12.0+