如何在flutter web中插入Adsense展示广告

Gau*_*ham 5 adsense flutter flutter-web

我制作了一个 320 像素 * 60 像素的固定展示广告。如何在我想要的地方插入颤振网络?这是我从adsense获得的代码:

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- MyAd -->
<ins class="adsbygoogle"
     style="display:inline-block;width:320px;height:60px"
     data-ad-client="xxxxxxxxx"
     data-ad-slot="xxxxxxxx"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
Run Code Online (Sandbox Code Playgroud)

或者是否有可能通过以某种方式操纵 flt-glass-pane 使 flutter 不占据屏幕底部 60 像素并在那里插入 AdSense 广告?

我正在寻找一种将 AdSense 广告插入到内置 flutter-web 的移动网站的方法

Gau*_*ham 9

我能够将广告插入到 flutter-web 中的列表视图中,如下所示:创建了一个 html 文件 adview.html

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
     style="display:inline-block;width:320px;height:80px"
     data-ad-client="ca-pub-xxxxxx"
     data-ad-slot="xxxxxxx"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
Run Code Online (Sandbox Code Playgroud)

然后,一个 IFrameElement 使用 html:

// ignore: avoid_web_libraries_in_flutter
import 'dart:html';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';

Widget adsenseAdsView() {
  // ignore: undefined_prefixed_name
  ui.platformViewRegistry.registerViewFactory(
      'adViewType',
      (int viewID) => IFrameElement()
        ..width = '320'
        ..height = '100'
        ..src = 'adview.html'
        ..style.border = 'none');

  return SizedBox(
    height: 100.0,
    width: 320.0,
    child: HtmlElementView(
      viewType: 'adViewType',
    ),
  );
}
Run Code Online (Sandbox Code Playgroud)

然后我们可以在我们想要的任何地方从函数 adsenseAdsView() 添加小部件。我把它添加到ListView中。

  • 是的,它有效,并且我在 Adsense 中获得了展示次数。 (2认同)
  • 您的 flutter 网站需要多长时间才能获得批准?您的网站已经有很多流量了吗? (2认同)
  • 您的申请如何获得批准?我收到了“有价值的库存:无内容”违规作为回复。我猜爬虫无法抓取纯 JS 应用程序。 (2认同)
  • 我已经建立了 www.droidbiz.in flutter 网站。我的 flutter 网站无法获得 AdSense 批准。它提供“有价值的库存:无内容”。你是怎么获得批准的? (2认同)