Skip to content

iOS API Reference ​

This document is the API reference manual for the UjuAd iOS SDK, covering all public enums and complete signatures of core classes. All content is verified against SDK source code for developers to reference during integration.

Reading Recommendations

  • For first-time integration, read SDK Initialization and Preparation first.
  • For specific usage of each ad type, refer to the Ad Type Integration documentation series.
  • This document only lists API signatures and field meanings; it does not include complete integration examples.

Enum Reference ​

AdFormat ​

Ad format enum, describing the 5 ad types supported by the SDK.

Enum ValueNumeric ValueMeaning
.splash0Splash ad
.banner1Banner ad
.native2Native/feed ad
.reward3Rewarded video
.interstitial4Interstitial ad

FeedType ​

Feed ad subtype enum, identifying the rendering mode. Obtained via UjuAdObject.getFeedType().

Enum ValueNumeric ValueMeaning
.express0Template rendering (SDK provides template, not enabled in current version)
.banner1Banner template (banner ads always return this value)
.native2Self-rendering (integrator provides view, native ads always return this value)
swift
let feedType = adObject.getFeedType()
switch feedType {
case .native:
    // Self-rendering, call getAdData() to get creatives and bind views yourself
case .banner:
    // Banner template
default:
    break
}

Current version rendering modes

In the current version, native ads getFeedType() always returns .native (self-rendering), and banner ads always return .banner. The .express template rendering mode will be supported in future versions.

AdMediaType ​

Media creative type for self-rendered ads.

Enum ValueNumeric ValueMeaning
.singleImage1Single image creative
.multiImage2Multi-image creative (image group)
.video3Video creative

AdBidType ​

Ad bidding type, identifying the bidding mode of the ad placement.

Enum ValueNumeric ValueMeaning
.normal0Normal mode (no bidding, waterfall direct run)
.adx1ADX mode (UjuAd self-owned ADX API)
.c2s2Client-to-server bidding (C2S)
.s2s3Server-to-server bidding (S2S)

AdPlatformType ​

Ad platform identifier enum, used to identify the ADN platform of the ad source.

Enum ValueNumeric ValuePlatform NameDescription
.csj1CSJByteDance ChuanShanJia (Pangle)
.ylh2YLHTencent YouLiangHui (GDT)
.bd3BaiduBaidu BaiQingTeng
.ks4KuaishouKuaishou Ads
.vivo13VIVOVIVO Ad Platform
.oppo14OPPOOPPO Ad Platform
.adx100ADXUjuAd internal ADX (platform ID is uniformly 100)

ADX Self-owned Ad Sources

ADX self-owned ad sources are built into the core library and require no additional registration. The ADX ad platform ID obtained via UjuAdInfo.platformId is uniformly 100.

UjuAdInitStatus ​

SDK initialization state enum, obtainable via UjuAdCore.shared.getInitializeState().

Enum ValueNumeric ValueMeaning
.idle0Idle state (not started)
.initializing1Initializing (start has been called, process is running)
.initialized2Initialization complete (ad APIs can be called)
.failed3Initialization failed (need to call start again)

UjuAdRegion ​

Service region enum. Integrators only need to select the region; all service hosts are automatically derived by the SDK.

Enum ValueMeaning
.domesticChina
.singaporeOverseas (Singapore)

Public API Reference ​

UjuAdCore ​

SDK global entry point, final class singleton (UjuAdCore.shared), annotated @unchecked Sendable. Responsible for SDK initialization, startup, state queries, and resource release.

Method List ​

Method SignatureReturn ValueDescription
initialize(_ application: AnyObject?, config: UjuAdInitConfig)VoidPhase 1 initialization, synchronously saves configuration, no privacy collection
start(_ listener: BaseInitListener?)VoidPhase 2 startup, collects device information and fetches strategies, calls back listener on completion
isSdkInitialized()BoolWhether initialize (phase 1) has completed
getInitializeState()UjuAdInitStatusGet SDK initialization state enum
getVersion()StringGet SDK version number (currently 3.4.8)
getAppId()StringGet current app ID
getRegion()UjuAdRegionGet service region
getIDFA()StringGet IDFA (returns empty string if unauthorized)
getIDFV()StringGet IDFV
requestAttAuthorization(completion:)VoidRequest ATT authorization
requestLocation(completion:)VoidOne-time location request
setIDFA(_:)VoidDeveloper-injected IDFA
setUserInfo(_:)VoidInject user information
setLocation(_:)VoidInject location information
updateChannel(channel:subChannel:)VoidUpdate channel and sub-channel
registerAdapterFactory(_:)BoolRegister a single adapter factory
destroy()VoidRelease SDK resources
swift
// 第一阶段:initialize(同步,不采集隐私)
UjuAdCore.shared.initialize(application, config: config)

// 第二阶段:start 并监听回调
UjuAdCore.shared.start(listener)

// 判断是否已完成 initialize
if UjuAdCore.shared.isSdkInitialized() { /* 可调用 start */ }

// 获取版本号
UjuAdCore.shared.getVersion()  // "3.4.8"

// 释放资源
UjuAdCore.shared.destroy()

Two-Phase Initialization

initialize() only saves configuration and does not perform any time-consuming operations; start() is what actually collects device information, fetches strategies, and initializes adapters. You must call initialize first, then start.

UjuAdObject ​

Unified ad object, final class, created via static factory methods (guarded by #if canImport(UIKit), iOS-only), carrying the ad's load, show, destroy, and other lifecycle operations.

Factory Methods (Static) ​

Method SignatureDescription
getSplashObject(_ vc: UIViewController, config: UjuAdConfig) -> UjuAdObjectCreate splash ad object
getRewardObject(_ vc: UIViewController, config: UjuAdConfig) -> UjuAdObjectCreate rewarded video ad object
getInterstitialObject(_ vc: UIViewController, config: UjuAdConfig) -> UjuAdObjectCreate interstitial ad object
getBannerObject(_ vc: UIViewController, config: UjuAdConfig) -> UjuAdObjectCreate banner ad object
getNativeObject(_ vc: UIViewController, config: UjuAdConfig) -> UjuAdObjectCreate native ad object

Instance Methods ​

Method SignatureReturn ValueDescription
setAdObjectListener(_:)VoidSet ad listener; type must match the ad type
load()VoidLoad ad, triggers bidding and request flow
show(_ vc: UIViewController)VoidShow ad (no container), for splash/reward/interstitial
show(_ vc: UIViewController, container: UIView)VoidShow ad (with container), for banner/native
isReady()BoolCheck whether the ad is ready to show
destroy()VoidDestroy ad object, release resources
getAdInfo()UjuAdInfo?Get ad info (price, platform, etc.); returns nil if not loaded
getFeedType()FeedType?Get feed rendering type (native always returns .native, banner always returns .banner)
getAdData()NativeAdData?Get self-rendered native creative data (only valid for native self-rendering)
registerViewForInteraction(vc:adView:container:binder:)VoidRegister self-rendered view, bind click interaction and creatives (native self-rendering only)

No pause/resume Methods

UjuAdObject does not have pause() and resume() methods. If you need to pause display, call destroy() to destroy and then recreate the object.

UjuAdInitConfig ​

SDK initialization configuration, struct (Sendable). init is private; must be constructed via the create(...) factory method.

create Parameters ​

ParameterTypeRequiredDefaultDescription
appIdStringYes—App ID
appKeyStringYes—RSA public key, pass as-is
channelStringNo"AppStore"Channel identifier
subChannelStringNo""Sub-channel
isDebugBoolNofalseDebug mode
wxAppIdString?NonilWeChat AppId
privacyConfigUjuPrivacyConfigNoUjuPrivacyConfig()Privacy authorization configuration
personalizationUjuPersonalizedConfigNoUjuPersonalizedConfig()Personalized recommendation configuration
presetStrategyFileNameString?NonilPreset strategy file name
regionUjuAdRegionNo.domesticService region
rsaPublicKeyStringNo""RSA public key (PEM), used for server-side communication encryption
loggerBackendUjuLoggerBackendNo.nsLogLog backend type (.nsLog / .osLog / .fileLog / .hybrid)
debugBidRequestBoolNofalseWhether to output BidRequest JSON debug logs (only effective when isDebug=true)
crashReportingEnabledBoolNotrueWhether to enable crash reporting
swift
let config = UjuAdInitConfig.create(
    appId: "YOUR_APP_ID",
    appKey: "YOUR_APP_KEY",
    channel: "AppStore",
    isDebug: true,
    region: .domestic,
    rsaPublicKey: "YOUR_RSA_PUBLIC_KEY"
)

UjuAdConfig ​

Ad request configuration, struct, passed in when creating each ad object, constructed directly via init.

FieldTypeRequiredDefaultDescription
placementIdStringYes—Ad placement ID
scenarioKeyString?NonilScenario identifier, used for analytics
adViewSizeAdViewSize?NonilPreferred banner / native size (in points). Since 3.4.6 it is used as the bid slot size and the budget-source template load size (width capped at the host window's current width); when nil, the current window width is used
userIdString?NonilUser ID, commonly used for rewarded video
customData[String: String]?NonilCustom data
bidFloorDoubleNo0.0Bid floor (CNY, CPM), passed by aggregation platform (e.g. ToBid), not needed for normal integrators

UjuPrivacyConfig ​

Privacy authorization configuration, struct (Sendable). All fields default to false (strictest privacy compliance). The integrator must explicitly enable them.

FieldTypeDefaultDescription
canUseIDFABoolfalseWhether IDFA usage is allowed (requires ATT authorization)
canUseIDFVBoolfalseWhether IDFV usage is allowed
canUseLocationBoolfalseWhether location usage is allowed
canUseImeiBoolfalseWhether IMEI usage is allowed (iOS typically does not allow; field retained for compatibility)
canUseOaidBoolfalseWhether OAID usage is allowed (iOS has no equivalent; field retained for compatibility)
canUseMacBoolfalseWhether MAC address usage is allowed (iOS typically does not allow; field retained for compatibility)

UjuPersonalizedConfig ​

Personalized recommendation configuration, struct (Sendable). All fields default to false (strictest compliance). The integrator must explicitly enable them.

FieldTypeDefaultDescription
personalizedRecommendBoolfalseWhether personalized recommendations are allowed
programmaticRecommendedBoolfalseWhether programmatic recommendations are allowed

UjuAdInfo ​

Ad information model, struct. Obtained via UjuAdObject.getAdInfo().

FieldTypeDescription
ecpmDoubleAd price (eCPM)
placementIdStringAd placement ID
soltIdStringAd placement slot ID (note: source code spelling is soltId)
platformIdIntPlatform ID, corresponds to the numeric value of AdPlatformType
adFormatAdFormatAd format
originalDoubleDataDouble?Original eCPM (unconverted)
loadIdStringLoad instance ID

Field Spelling Note

The slot ID field in UjuAdInfo is spelled soltId (not slotId). This is the actual spelling in the source code; please keep it consistent when using.

NativeAdData ​

Native ad self-rendering creative data, struct. Obtained via UjuAdObject.getAdData(). All fields are optional.

FieldTypeDescription
titleString?Ad title
descString?Ad description
sourceString?Ad source
callToActionString?Call-to-action text (e.g. "Download Now")
imageUrlString?Single image URL
imageUrlList[String]?Multi-image URL list
iconUrlString?Icon URL

NativeAdViewBinder ​

Native ad view binder, struct, using the view.tag pattern. Only titleTag is required; others default to 0/[] to indicate no binding.

FieldTypeRequiredDefaultDescription
titleTagIntYes—Title view tag
descTagIntNo0Description view tag
sourceTagIntNo0Source view tag
imageTagIntNo0Main image view tag
mediaViewTagIntNo0Media view tag (for video ads)
iconTagIntNo0Icon view tag
callToActionTagIntNo0Call-to-action button tag
logoTagIntNo0Ad logo tag
clickViewTags[Int]No[]Additional clickable view tag list
dislikeTagIntNo0Dislike button tag

AdViewSize ​

Ad size configuration, struct (Sendable), in points (pt, same unit as UIView sizes). Only effective for banner and native template ads. Since 3.4.6, when set, the SDK uses it as the bid slot size and every budget source's template load size (width capped at the host window's current width); when unset, the current window width is used and follows fold / unfold on foldable devices.

FieldTypeDescription
widthCGFloatWidth (points)
heightCGFloatHeight (points)

Preset Sizes (Static Properties) ​

Preset PropertyWidth × HeightDescription
AdViewSize.bannerSize320x50320 × 50Standard Banner
AdViewSize.bannerSize320x100320 × 100Large Banner
AdViewSize.bannerSize320x75320 × 75Smart Banner
AdViewSize.nativeSize600x200600 × 200Native Self-rendering
AdViewSize.nativeSize690x388690 × 388Native Feed Card
swift
// 使用预设
let size = AdViewSize.bannerSize320x50

// 自定义尺寸
let custom = AdViewSize(width: 300, height: 250)

Listener Interfaces ​

The SDK provides a set of listener protocols, differentiated by ad type. All ad listeners inherit from BaseAdObjectListener. All methods have default empty implementations, so callers can implement only the callbacks they care about.

Inheritance Hierarchy ​

BaseAdObjectListener
├── FeedAdObjectListener            (横幅 / 原生信息流)
├── SplashAdObjectListener          (开屏)
├── InterstitialAdObjectListener    (插屏)
└── RewardAdObjectListener          (激励视频)

BaseInitListener                    (SDK 初始化,独立接口)

BaseAdObjectListener ​

Base protocol for all ad object listeners (AnyObject).

Method SignatureDescription
onLoadSuccess()Ad loaded successfully (no parameters)
onLoadError(error: UjuException)Ad load failed (1 parameter)
onAdShow()Ad displayed
onAdClicked()Ad clicked
onAdClosed()Ad closed
onAdError(error: UjuException)Ad show phase error (1 parameter)

Parameter Count

iOS's onLoadSuccess() has no parameters. Both onLoadError(error:) and onAdError(error:) take 1 parameter (error). This differs from Android (Android's onLoadSuccess has a placementId parameter, and onLoadError has 2 parameters).

FeedAdObjectListener ​

Banner and native feed listener, inherits BaseAdObjectListener.

Method SignatureDescription
onAdSizeChanged(width: CGFloat, height: CGFloat)Ad view size changed (new in 3.4.6, main thread). Called when the container width changes (foldable fold / unfold, Split View, rotation) and the ad re-lays out to a new height; not called for the initial render. List-based hosts can refresh row heights here
onLpClosed()Landing page closed

SplashAdObjectListener ​

Splash ad listener, inherits BaseAdObjectListener.

Method SignatureDescription
onAdDismissed()Splash dismissed (user skipped or countdown ended)

InterstitialAdObjectListener ​

Interstitial ad listener, inherits BaseAdObjectListener.

Method SignatureDescription
onAdPlayComplete()Interstitial playback completed

RewardAdObjectListener ​

Rewarded video listener, inherits BaseAdObjectListener.

Method SignatureDescription
onAdRewardArrived()Grant reward (no parameters)
onAdPlayComplete()Video playback completed
onAdSkippedVideo()User skipped video

onAdRewardArrived Has No Parameters

onAdRewardArrived() has no parameters. If you need to customize reward information, verify it via S2S callback on the server side.

BaseInitListener ​

SDK initialization listener, standalone interface (AnyObject, Sendable), callbacks on MainActor (main thread).

Method SignatureDescription
onInitSuccess()SDK initialization succeeded
onInitFailed(error: UjuException)SDK initialization failed