# 广告网络

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

广告代码是 JavaScript，页面能跑的地方它就能跑，所以 PWA 要问的不是网络的代码能否加载，而是网络的政策是否覆盖页面所处的场景：浏览器标签页、已安装的独立窗口、Trusted Web Activity，或原生应用的 WebView。Google 的 AdSense 政策恰好区分了这四种场景；带日期的逐网络结论见[政策维度](/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，按 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」 |

## 实测行为

:::observed
2026-08-04 版 AdSense 计划政策页面在「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/)总览。