ORTB
OMID 分册导航

iOS / tvOS

平台

本页清单由 scripts/gen-omid-spec.mjs 自 IAB Tech Lab 官方源生成,描述为官方英文原文;采集基线见页尾。 规范收录数据保留英文原文;已提供的中文译文为初稿(draft),打开中英对照可查看原文。

本页目录

定位与职责

OM SDK iOS 以开放测量接口定义(Open Measurement Interface Definition,OMID)为前缀的 Objective-C 类暴露接口:OMIDSDK 负责激活与状态查询,OMIDAdSession 由 OMIDAdSessionConfiguration 与 OMIDAdSessionContext 构造,OMIDScriptInjector 向 WebView 注入会话客户端,OMIDJavaScriptSessionService 承载 JS 会话的服务端。友好遮挡(friendly obstruction)注册 API 仅原生端提供。

iOS
实现
OM SDK iOS
库版本
规范版本
OMID 1.6
公开类
12
公开成员
74

平台要点

  • 入口类为 OMIDSDK,公开 versionString、sharedInstance、active、activate 与 updateLastActivity;会话由 OMIDAdSessionConfiguration 与 OMIDAdSessionContext 经 initWithConfiguration:adSessionContext:error: 构造 OMIDAdSession。
  • OMIDScriptInjector 以 injectScriptContent:intoHTML:error: 把会话客户端注入 HTML;OMIDJavaScriptSessionService 承载 JS 会话的服务端。
  • 友好遮挡(friendly obstruction)注册 API 仅原生端提供:OMIDAdSession 暴露 addFriendlyObstruction:purpose:detailedReason:error:、removeFriendlyObstruction: 与 removeAllFriendlyObstructions,遮挡用途由 OMIDFriendlyObstructionType 枚举声明(该枚举仅 iOS 端存在)。
  • OMIDUniversalAdID 与 OMIDVASTProperties 在 iOS 端是独立公开类,而 JS 端对应类型未由官方文档站发布。
  • 官方参考应用仓库 Open-Measurement-ReferenceApp-iOS 自 2020-04 起停止更新,其 README 明示自 iOS SDK 1.3.2 起示例源码随可下载 SDK 一并提供;当前 API 面以 docs.iabtechlab.com/omsdk-1.6/ios 为准。

公开类清单

客户端成员数官方描述
OMIDAdEvents官方文档会话客户端4initWithAdSession:error:impressionOccurredWithError:loadedWithError:loadedWithVastProperties:error:广告事件 API:供集成方(integration partner)在关键事件发生时向所有验证提供方(verification provider)发出信号。同一广告会话只能关联一个广告事件实现,创建多个实例将导致错误。ENAd event API enabling the integration partner to signal to all verification providers when key events have occurred. Only one ad events implementation can be associated with the ad session and any attempt to create multiple instances will result in an error.译稿校对中
OMIDAdSession官方文档会话客户端9configurationmainAdViewinitWithConfiguration:adSessionContext:error:startfinishaddFriendlyObstruction:purpose:detailedReason:error:removeFriendlyObstruction:removeAllFriendlyObstructionslogErrorWithType:message:广告会话 API:供集成方(integration partner)向 OMID 通报与可见性(viewability)计算相关的关键状态。除可见性外,本 API 还会向所有验证提供方通报广告会话生命周期的关键事件。ENAd session API enabling the integration partner to notify OMID of key state relating to viewability calculations. In addition to viewability this API will also notify all verification providers of key ad session lifecycle events.译稿校对中
OMIDAdSessionConfiguration官方文档会话客户端6creativeTypeimpressionTypeimpressionOwnermediaEventsOwnerisolateVerificationScriptsinitWithCreativeType:impressionType:impressionOwner:mediaEventsOwner:isolateVerificationScripts:error:广告会话配置指明曝光事件与视频事件各自的归属方(owner)。OM SDK JS 服务会用该信息辅助判断应从何处接收这些事件的来源。ENThe ad session configuration supplies the owner for both the impression and video events. The OM SDK JS service will use this information to help identify where the source of these events is expected to be received.译稿校对中
OMIDAdSessionContext官方文档会话客户端5initinitWithPartner:webView:contentUrl:customReferenceIdentifier:error:initWithPartner:script:resources:contentUrl:customReferenceIdentifier:error:initWithPartner:script:resources:contentUrl:customReferenceIdentifier:universalAdID:error:initWithPartner:javaScriptWebView:contentUrl:customReferenceIdentifier:error:向广告会话提供集成方(partner)详情,以及本次会话属于 HTML、JavaScript 还是原生(native)会话。ENProvides the ad session with details of the partner and whether to an HTML, JavaScript, or native session.译稿校对中
OMIDJavaScriptSessionService官方文档会话客户端7initWithPartner:webView:isHTMLAdView:error:tearDownWithCompletion:adViewsetAdView:error:addFriendlyObstruction:purpose:detailedReason:error:removeFriendlyObstruction:removeAllFriendlyObstructions通过提供原生层测量信号,支持以 JavaScript 会话客户端 API 管理(启动/结束)的广告会话。若 JS 会话客户端运行在 web view 中,则必须先以该 web view 初始化本服务的一个实例,之后才能用 JS API 启动或结束广告会话。同一 web view 在同一时间只允许初始化一个本服务实例;要复用该 web view,必须先销毁当前实例(见 tearDownWithCompletion)。ENService supporting ad sessions managed (started/finished) via JavaScript Session Client APIs by providing native-layer measurement signals. If the JS Session Client is running in a web view, an instance of this service must be initialized with the web view before starting or finishing ad sessions using JS APIs. Only one instance of this service may be initialized at a time for a given web view; to reuse a web view the current instance must be torn down (see tearDownWithCompletion).译稿校对中
OMIDMediaEvents官方文档会话客户端14initWithAdSession:error:startWithDuration:mediaPlayerVolume:firstQuartilemidpointthirdQuartilecompletepauseresumeskippedbufferStartbufferFinishvolumeChangeTo:playerStateChangeTo:adUserInteractionWithType:提供 OMID 支持的原生媒体事件完整列表。使用该事件 API 意味着媒体播放器全权负责在恰当时机上报所有媒体事件。同一广告会话只能关联一个媒体事件实现,创建多个实例将导致错误。ENThis provides a complete list of native media events supported by OMID. Using this event API assumes the media player is fully responsible for communicating all media events at the appropriate times. Only one media events implementation can be associated with the ad session and any attempt to create multiple instances will result in an error.译稿校对中
OMIDPartner官方文档会话客户端4nameversionStringinitWithName:versionString:init将提供给广告会话的集成方(integration partner)详情。ENDetails about the integration partner which will be supplied to the ad session.译稿校对中
OMIDScriptInjector官方文档会话客户端1injectScriptContent:intoHTML:error:工具类:让集成方以标准方式将 OM SDK JS 注入所投放的 tag HTML 内容中。ENUtility class which enables integration partners to use a standard approach for injecting OM SDK JS into the served tag HTML content.译稿校对中
OMIDSDK官方文档会话客户端5versionStringsharedInstanceactiveactivateupdateLastActivity应用级类:所有集成方都必须调用它,以确保在调用任何其他 API 方法之前 OM SDK 已被激活。激活前使用其他 API 方法将导致错误。注意 OM SDK 只能在主 UI 线程上使用:初始化 SDK、创建其对象、调用其方法时,都必须确保处于主线程。ENThis application level class will be called by all integration partners to ensure OM SDK has been activated before calling any other API methods. Any attempt to use other API methods prior to activation will result in an error. Note that OM SDK may only be used on the main UI thread. Make sure you are on the main thread when you initialize the SDK, create its objects, and invoke its methods.译稿校对中
OMIDUniversalAdID官方文档会话客户端5valueidRegistryinitWithValue:idRegistry:error:newinit将提供给广告会话的 UniversalAdID 详情,用于跟踪广告创意(creative)。ENDetails about the UniversalAdID for the purpose of tracking ad creatives which will be supplied to the ad session.译稿校对中
OMIDVASTProperties官方文档会话客户端8skippableskipOffsetautoPlaypositioninitWithSkipOffset:autoPlay:position:initWithAutoPlay:position:inittoJSON该对象用于记录关键的 VAST 属性,以便与所有已注册的验证提供方共享。ENThis object is used to capture key VAST properties so this can be shared with all registered verification providers.译稿校对中
OMIDVerificationScriptResource官方文档会话客户端6URLvendorKeyparametersinitWithURL:vendorKey:parameters:initWithURL:init将提供给广告会话的验证提供方(verification provider)详情。ENDetails about the verification provider which will be supplied to the ad session.译稿校对中

跨平台命名对照

概念JavaScriptiOSAndroid
ad-eventsAdEventsOMIDAdEventsAdEvents
ad-sessionAdSessionOMIDAdSessionAdSession
ad-session-configurationOMIDAdSessionConfigurationAdSessionConfiguration
ad-session-contextOMIDAdSessionContextAdSessionContext
contextContext
js-session-serviceOMIDJavaScriptSessionService
media-eventsMediaEventsOMIDMediaEventsMediaEvents
omid-versionOmidVersion
partnerPartnerOMIDPartnerPartner
script-injectorOMIDScriptInjectorScriptInjector
sdk-entryOMIDSDKOmid
universal-ad-idOMIDUniversalAdID
vast-propertiesOMIDVASTPropertiesVastProperties
verification-clientVerificationClient
verification-script-resourceVerificationScriptResourceOMIDVerificationScriptResourceVerificationScriptResource
  • ad-session-configurationJS 无对应类:creativeType/impressionType 由 AdSession.setCreativeType()/setImpressionType() 设置,事件 owner(impressionOwner/mediaEventsOwner)概念在 JS 侧不存在。
  • ad-session-context对应 JS 的 Context:JS 把 partner、verificationScriptResources、contentUrl、customReferenceData、universalAdId 与 slot/video element 折叠进 Context 及 AdSession 构造参数,原生侧则拆为 AdSessionContext(iOS 另有 AdSessionConfiguration)。
  • contextiOS/Android 无同名类:JS 的 Context 在原生侧被拆分为 AdSessionContext + AdSessionConfiguration(见 ad-session-context / ad-session-configuration 两条)。
  • js-session-service仅 iOS 公开:OM SDK iOS 内置的 JS 会话服务(Android 由 Omid/OmidJsBridge 承担,未在 javadoc 站点公开对应类)。
  • omid-version仅 JS 公开:源码 omid-version.js 顶部有 TODO(OMSDK-715) 注明该类似未使用、下个大版本应移除,但 JSDoc 站点仍发布。
  • script-injectoriOS OMIDScriptInjector / Android ScriptInjector:把验证脚本内容注入 HTML 创意;JS 侧由 OM SDK service 完成,无公开类。
  • sdk-entryiOS 为 OMIDSDK(+sharedInstance / -activate),Android 为 Omid(activate(Context) / isActive());JS 侧无对应类,服务脚本由 OM SDK service 自行装载。
  • universal-ad-id仅 iOS 公开:JS 源码有 UniversalAdId(packageExport 到 OmidSessionClient.UniversalAdId,1.5.5 新增)但官方 JSDoc 站点无对应页面;Android 的 createNativeAdSessionContext(...)/getUniversalAdId() 在签名中引用 UniversalAdId 类型,javadoc 站点亦无该页(实测 404)。
  • vast-propertiesJS 侧 VastProperties(src/common/vast-properties.js,标 @public 且在 jsdoc.json 的 include 列表内)未被官方 JSDoc 站点发布(VastProperties.html 实测 404),故 js 记 null;AdEvents.loaded(vastProperties) 因此引用了一个站点上没有文档的类型。
  • verification-client仅 JS 公开:验证脚本(第三方测量)一律使用 JS 的 OmidVerificationClient,原生 SDK 不含验证客户端。

同一概念在三端的类名对照;空缺表示该端不提供对应类。JS 侧把会话配置折进 Context 与构造参数,iOS / Android 侧则拆为独立的配置与上下文类。

内容取自 IAB Tech Lab 官方源(OM SDK JS 仓库、三端官方 API 文档、OpenRTB 支持通告与 VAST 规范);规范收录数据保留英文原文,站内撰写文案为中英双语。溯源见 data/omid-spec/PROVENANCE.json。