OMID 分册导航
Android
平台本页清单由 scripts/gen-omid-spec.mjs 自 IAB Tech Lab 官方源生成,描述为官方英文原文;采集基线见页尾。 规范收录数据保留英文原文;已提供的中文译文为初稿(draft),打开中英对照可查看原文。
定位与职责
OM SDK Android 以 com.iab.omid.library 包暴露接口:Omid.activate 完成初始化,AdSession 由 AdSessionConfiguration 与 AdSessionContext 构造,VerificationScriptResource 提供带参与不带参两种工厂方法,广告事件与媒体事件分别在 adsession 与 adsession.media 包下。
- 端
- Android
- 实现
- OM SDK Android
- 库版本
- —
- 规范版本
- OMID 1.6
- 公开类
- 10
- 公开成员
- 66
平台要点
- 入口类为 Omid,公开 activate、updateLastActivity、getVersion 与 isActive;会话由 AdSessionConfiguration 与 AdSessionContext 经 AdSession.createAdSession 构造。
- 公开类分布在三个包:com.iab.omid.library(Omid、ScriptInjector)、com.iab.omid.library.adsession(AdEvents、AdSession、AdSessionConfiguration、AdSessionContext、Partner、VerificationScriptResource)、com.iab.omid.library.adsession.media(MediaEvents、VastProperties)。
- Android 端没有 VerificationClient 类:验证脚本一律使用 JS 验证客户端。
- 各类均无公开字段,实例创建一律走静态工厂方法(createAdSession、createAdEvents、createMediaEvents、createPartner、createAdSessionContext、createAdSessionConfiguration、createVerificationScriptResourceWithParameters / WithoutParameters、createVastProperties 等)。
- 广告视图与遮挡在原生端通过 AdSession 的 registerAdView、addFriendlyObstruction、removeFriendlyObstruction、removeAllFriendlyObstructions 与 setPossibleObstructionListener 处理。
- 官方参考应用仓库 Open-Measurement-ReferenceApp-Android 停在 2020-01(OM SDK 1.3 之前);当前 API 面以 docs.iabtechlab.com/omsdk-1.6/android 为准。
公开类清单
| 类 | 客户端 | 成员数 | 官方描述 |
|---|---|---|---|
| AdEvents官方文档 ↗ | 会话客户端 | 4createAdEventsimpressionOccurredloaded()loaded(VastProperties) | 广告事件 API:供集成方(integration partner)在关键事件发生时向所有验证提供方(verification provider)发出信号。同一广告会话只能关联一个广告事件实现,创建多个实例将抛出异常(exception)。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 exception. Created by Natasha Garner on 04/09/2017.译稿校对中 |
| AdSession官方文档 ↗ | 会话客户端 | 10AdSessionstarterrorregisterAdViewfinishaddFriendlyObstructionremoveFriendlyObstructionremoveAllFriendlyObstructionssetPossibleObstructionListenercreateAdSession | 广告会话 API:供集成方(integration partner)向 OM SDK 通报与可见性(viewability)计算相关的关键状态。除可见性外,本 API 还会向所有验证提供方通报广告会话生命周期的关键事件。ENAd session API enabling the integration partner to notify OM SDK 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.译稿校对中 |
| AdSessionConfiguration官方文档 ↗ | 会话客户端 | 4createAdSessionConfigurationisNativeImpressionOwnerisNativeMediaEventsOwnertoJsonObject | 官方文档未提供该类的功能描述(原 Javadoc 仅含作者与创建日期)。ENCreated by pharris on 11/09/2017.译稿校对中 |
| AdSessionContext官方文档 ↗ | 会话客户端 | 13createHtmlAdSessionContextcreateJavascriptAdSessionContextcreateNativeAdSessionContext(Partner,String,List,String,String,UniversalAdId)createNativeAdSessionContext(Partner,String,List,String,String)getPartnergetVerificationScriptResourcesgetInjectedResourcesMapgetWebViewgetContentUrlgetCustomReferenceDatagetOmidJsScriptContentgetAdSessionContextTypegetUniversalAdId | 该类向广告会话提供集成方(partner)详情,以及本次会话被视为 HTML 还是原生(native)会话。ENThis class will provide the ad session both details of the partner and whether this is considered HTML or native. Created by Natasha Garner on 01/08/2017.译稿校对中 |
| MediaEvents官方文档 ↗ | 会话客户端 | 14createMediaEventsstartfirstQuartilemidpointthirdQuartilecompletepauseresumebufferStartbufferFinishskippedvolumeChangeplayerStateChangeadUserInteraction | 提供 OM SDK 支持的原生媒体事件完整列表。使用该事件 API 意味着原生层的音视频播放器全权负责在恰当时机上报所有媒体事件。同一广告会话只能关联一个媒体事件实现,创建多个实例将抛出异常。ENThis provides a complete list of native media events supported by OM SDK. Using this event API assumes the native-layer audio/video 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 exception. Created by Natasha Garner on 10/09/2017.译稿校对中 |
| Omid官方文档 ↗ | 会话客户端 | 4activateupdateLastActivitygetVersionisActive | 应用级类:所有集成方都必须调用它,以确保在调用任何其他 API 方法之前 OM SDK 已被激活。激活前使用其他 API 方法将抛出异常(exception)。注意 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 exception. 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. Created by Natasha Garner on 20/06/2017.译稿校对中 |
| Partner官方文档 ↗ | 会话客户端 | 3createPartnergetNamegetVersion | 将提供给广告会话的集成方(integration partner)详情。ENDetails about the integration partner which will be supplied to the ad session. Created by Natasha Garner on 01/08/2017.译稿校对中 |
| ScriptInjector官方文档 ↗ | 会话客户端 | 1injectScriptContentIntoHtml | 工具类:让集成方以标准方式将 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.译稿校对中 |
| VastProperties官方文档 ↗ | 会话客户端 | 7createVastPropertiesForSkippableMediacreateVastPropertiesForNonSkippableMediaisSkippablegetSkipOffsetisAutoPlaygetPositiontoJSON | 该对象用于记录关键的 VAST 属性,以便与所有已注册的验证提供方共享。ENThis object is used to capture key VAST properties so this can be shared with all registered verification providers. Created by Natasha Garner on 09/09/2017.译稿校对中 |
| VerificationScriptResource官方文档 ↗ | 会话客户端 | 6createVerificationScriptResourceWithParameterscreateVerificationScriptResourceWithoutParametersgetVendorKeygetResourceUrlgetVerificationParameterstoJsonObject | 将提供给广告会话的验证提供方(verification provider)详情。ENDetails about the verification provider which will be supplied to the ad session. Created by Natasha Garner on 02/08/2017.译稿校对中 |
跨平台命名对照
| 概念 | JavaScript | iOS | Android |
|---|---|---|---|
| ad-events | AdEvents | OMIDAdEvents | AdEvents |
| ad-session | AdSession | OMIDAdSession | AdSession |
| ad-session-configuration | — | OMIDAdSessionConfiguration | AdSessionConfiguration |
| ad-session-context | — | OMIDAdSessionContext | AdSessionContext |
| context | Context | — | — |
| js-session-service | — | OMIDJavaScriptSessionService | — |
| media-events | MediaEvents | OMIDMediaEvents | MediaEvents |
| omid-version | OmidVersion | — | — |
| partner | Partner | OMIDPartner | Partner |
| script-injector | — | OMIDScriptInjector | ScriptInjector |
| sdk-entry | — | OMIDSDK | Omid |
| universal-ad-id | — | OMIDUniversalAdID | — |
| vast-properties | — | OMIDVASTProperties | VastProperties |
| verification-client | VerificationClient | — | — |
| verification-script-resource | VerificationScriptResource | OMIDVerificationScriptResource | VerificationScriptResource |
- 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 侧则拆为独立的配置与上下文类。