Skip to main content
RevIQ 适用于任何使用 Web 技术渲染界面的桌面应用。只要您的应用在窗口中显示 HTML,就可以通过 RevIQ 实现变现。 RevIQ works in any desktop app that renders its UI with web technology. If your app shows HTML in a window, you can monetize it with RevIQ.

支持的框架 Supported frameworks

  • Electron:通过 rev-utils 辅助库提供官方支持(见下文) Electron, with first-class support through the rev-utils helper
  • Tauri
  • NW.js、CEF、Wails、Neutralino 等基于 Chromium 或 webview 的框架 NW.js, CEF, Wails, Neutralino and other Chromium- or webview-based frameworks
  • 内嵌 webview 的原生应用:WebView2(Windows)、WKWebView(macOS)、WebKitGTK(Linux) Native apps with an embedded webview: WebView2 (Windows), WKWebView (macOS) and WebKitGTK (Linux)
像在网站上一样,将 RevIQ 脚本添加到应用加载的页面中,参见Frontend。然后确保您的应用满足以下两项桌面要求。 Add the RevIQ script to the page your app loads, the same way you would on a website. See Frontend. Then make sure your app meets the two desktop requirements below.

桌面要求 Desktop requirements

  1. 在用户的默认浏览器中打开广告点击。 用户点击广告时,请在默认浏览器中打开落地页,而不是在应用窗口内跳转。仅在用户真实点击时打开链接;拦截非用户触发的跳转和弹窗,以及由广告发起的文件下载。 Open ad clicks in the user’s default browser. When someone clicks an ad, open the landing page in their default browser rather than navigating your app’s window. Only open links in response to a real click. Block navigations and popups the user didn’t trigger, and block file downloads started by ads.
  2. 发送标准的浏览器 User Agent。 许多框架会在 User Agent 字符串中加入框架名称和应用名称(例如 Electron/…MyApp/…)。请移除这些部分,使其与普通浏览器一致。非标准的 User Agent 可能被判定为无效流量(IVT)。 Send a standard browser User Agent. Many frameworks add their own name, and your app’s name, to the User Agent string (for example Electron/… or MyApp/…). Remove those parts so the string looks like a regular browser. Non-standard User Agents may be flagged as IVT (invalid traffic).

Electron

rev-utils 会为您处理这两项要求。 rev-utils handles both requirements for you.

安装 Installation

安装rev-utils库,为您的 Electron 应用添加完整的广告支持。我们可能会不定期更新该包。 Install the rev-utils library to augment your Electron setup with full compatibility for ads. We may occasionally update the package.

使用方法 Usage

使用new BrowserWindow创建新窗口后,将窗口对象和electron全局变量传入 setupRevUtils。 After creating a window with new BrowserWindow, pass the window and the electron global into setupRevUtils.
main.js
setupRevUtils在底层调用了窗口的两个函数: -setupLinkHandler:用于打开广告(同时拦截恶意行为!) -setUserAgent:用于移除User Agent字符串中的非标准部分,这些非标准内容可能触发无效流量(IVT)检测。 Under the hood, setupRevUtils calls two functions on the window - setupLinkHandler to open ads (and block malicious behavior!) - setUserAgent, which removes non-standard portions of the User Agent string which may trigger IVT (invalid traffic).

Tauri

在您的域名上建立一个包含 RevIQ 脚本和广告位的页面(参见Frontend),然后在一个发送标准 User Agent、并在用户浏览器中打开广告点击的子 webview 中显示它。 Build a page on your domain with the RevIQ script and your ad slots (see Frontend), then show it in a child webview that sends a standard User Agent and opens ad clicks in the user’s browser.
src-tauri/src/ads.rs
Window::add_child 属于 Tauri 的 unstable 功能。请在 src-tauri/Cargo.tomltauri 中启用:tauri = { version = "2", features = ["unstable"] }Window::add_child is behind Tauri’s unstable feature. Enable it on tauri in src-tauri/Cargo.toml: tauri = { version = "2", features = ["unstable"] }.
该脚本会在 webview 的每个框架中运行。广告渲染在 iframe 中,因此每个框架都会上报点击,并把链接交给您的页面,页面仅在用户真实点击后才打开链接。 The webview runs this script in every frame. Ads render inside iframes, so each frame reports clicks and passes links up to your page, which opens them only right after a real click.
src-tauri/src/ads-init.js
注册 opener 插件和命令: Register the opener plugin and the command:
src-tauri/src/main.rs
广告页面从您的域名加载(属于远程内容),因此除非通过 capability 允许该来源,否则 Tauri 会阻止它调用命令。只授予 ads webview 所需的这一个命令: Because the ad page is loaded from your domain (remote content), Tauri blocks it from calling commands unless a capability opts that origin in. Grant the ads webview only the one command it needs:
src-tauri/capabilities/ads.json
为该命令定义权限: Define that permission for your command:
src-tauri/permissions/open-ad-link.toml
在 Windows 上,请将广告 webview 的跟踪防护级别设为无:通过 with_webviewCOREWEBVIEW2_TRACKING_PREVENTION_LEVEL_NONE 调用 ICoreWebView2Profile3::SetPreferredTrackingPreventionLevel。否则 WebView2 会拦截竞价方用于识别回访用户的 Cookie,从而降低出价。 On Windows, set the ads webview’s tracking prevention level to none: call ICoreWebView2Profile3::SetPreferredTrackingPreventionLevel with COREWEBVIEW2_TRACKING_PREVENTION_LEVEL_NONE through with_webview. WebView2 otherwise blocks the cookies bidders use to recognize returning users, which lowers bids.

其他框架 Other frameworks

使用您所用框架自身的 API 满足这两项要求:为 webview 设置标准的浏览器 User Agent,并且仅在用户真实点击后,将广告框架中的链接点击和 window.open 调用在系统浏览器中打开。完整方案请参见上面的 Tauri 示例。 Meet the two requirements with your framework’s own APIs: set a standard browser User Agent on the webview, and send link clicks and window.open calls from ad frames to the system browser, only right after a real click. The Tauri example above shows the full pattern.
使用的框架未在此列出?只要它能渲染 Web 内容即可正常工作。如需设置方面的帮助,请联系您的 RevIQ 客户经理。 Building with a framework not listed here? It will work as long as it renders web content. Contact your RevIQ account manager if you need help with setup.