# 广告网络

> 广告网络的书面政策允许其代码在 PWA 的哪些场景运行：浏览器标签页、已安装的独立窗口、Trusted Web Activity 或原生 WebView，并逐条引用 AdSense 与 AdMob 的规则。

广告代码用 JavaScript 在网页中展示广告，页面能运行的地方它也能运行。PWA 还要核对广告网络是否允许对应的展示场景。Google AdSense 政策区分浏览器标签页、已安装的独立窗口、Trusted Web Activity 和原生应用 WebView 这四种场景，各网络的结论和核对日期见[政策维度](/zh/compatibility/policy/)。

## 工作原理

Web 广告网络授权网页使用广告代码，应用内广告则使用单独的移动端 SDK。具体边界由政策规定。AdSense 按内容显示在什么界面中区分，不按页面是否已安装区分。

### 浏览器标签页或已安装的 PWA

AdSense 计划政策（2026-08-04 最近更新）按表面限制投放：「AdSense code may not be placed in inappropriate places such as pop-ups, emails or software」，广告也不得「integrated into a software application (does not apply to AdMob) of any kind, including toolbars」。从 Chrome、Edge 或 Safari 安装的 PWA 仍由该浏览器从你的源渲染；政策没有点名任何显示模式，也没有对 `standalone` 附加条件。变化的是度量环境：`(display-mode: standalone)` 媒体查询会匹配，从 Microsoft Store 安装的应用在首次导航时会发送 `Referer: app-info://platform/microsoft-store`（[Microsoft Learn](https://learn.microsoft.com/en-us/microsoft-edge/progressive-web-apps/how-to/microsoft-store)），所以按 referrer 域名分组的报表会把这类会话与标签页流量分开。

### Trusted Web Activity 或 Custom Tab

同一政策有一节「Technical requirements for web content viewing frames for apps」。其第二个选项列出了可以从应用内展示 AdSense 与 Ad Manager Web 广告的框架：「Android: Chrome Custom Tabs and Trusted Web Activities」以及「iOS: SFSafariViewController (iOS9 and iOS10 only)」。因此 Google Play 上的 TWA 可以沿用其封装站点的 Web 广告代码；Play 上架本身受[商店政策](/zh/ecosystem/stores/)中描述的垃圾内容与付款政策约束。

### 原生 WebView

对 Android `WebView` 或 iOS `WKWebView`，适用该节的第一个选项：「app developers are encouraged to integrate the WebView API for Ads to register WebView instances」并使用 Google Mobile Ads SDK，且「AdMob and Ad Manager in-app ads may be shown in an app next to a WebView as long as the Google Mobile Ads SDK is in use」。政策补充「content in the WebView is subject to the same content policy requirement as when it is in a browser」。这种集成方式适用 AdMob 的结算条款，不适用 AdSense 的条款。

### 政策没有说清的部分

AdSense 文本没有提到 WebAPK、桌面已安装窗口或 Service Worker。Service Worker 返回缓存的 HTML 时，无需向网络请求页面就能再次显示页面和广告位，因此展示次数取决于广告代码发出的请求，不取决于页面加载。已安装窗口没有浏览器外壳，若可见性测量假定标签栏可见，就会量到略大的视口。这两种情况源于页面的加载和显示方式，都不违反政策；上线前仍应对照广告网络的无效流量指引核对。

| 场景 | AdSense Web 代码 | 所需集成 | 政策依据 |
|---|---|---|---|
| 浏览器标签页 | 允许 | 无 | 计划政策，广告投放位置 |
| 已安装 PWA（WebAPK、桌面窗口） | 文本未加限制 | 无 | 计划政策未点名显示模式 |
| Trusted Web Activity / Custom Tab | 允许 | 无 | 「Web content viewing frames」选项 2 |
| 原生 WebView | 不允许直接投放 | WebView API for Ads + Google Mobile Ads SDK | 「Web content viewing frames」选项 1 |
| 原生应用界面 | 不允许 | AdMob | 「does not apply to AdMob」 |

## 实测行为

:::note
[AdSense Program policies](https://support.google.com/adsense/answer/48182) 页面（2026-08-04 更新）在「Technical requirements for web content viewing frames for apps」一节写下了对封装型 PWA 起决定作用的两句话。选项 1：「App developers are encouraged to integrate the WebView API for Ads to register WebView instances」。选项 2 把「Android: Chrome Custom Tabs and Trusted Web Activities」列为其他受支持的框架，可不用 SDK 发布 Web 广告。iOS 一侧的框架限定为「SFSafariViewController (iOS9 and iOS10 only)」，所以运行在更新系统上的 iOS 壳只能回到选项 1。
:::

## 另请参阅

- [AdSense Program policies](https://support.google.com/adsense/answer/48182)（support.google.com）
- [display-mode 媒体特性](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/display-mode)（developer.mozilla.org）
- [广告网络政策数据](/zh/compatibility/policy/)
- [变现](/zh/ecosystem/monetization/)
- [商店政策](/zh/ecosystem/stores/)
- [Trusted Web Activity](/zh/reference/installation/twa/)

← 返回[生态](/zh/ecosystem/)总览。