【问题标题】:How to insert Adsense display ad in flutter web如何在 Flutter Web 中插入 Adsense 展示广告
【发布时间】:2021-01-07 03:54:42
【问题描述】:

我制作了一个 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>

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

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

【问题讨论】:

    标签: flutter adsense flutter-web


    【解决方案1】:

    我能够在 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>
    

    然后,使用 html 的 IFrameElement:

    // 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',
        ),
      );
    }
    

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

    【讨论】:

    • 成功了吗?您是否在 Adsense 帐户中获得了展示次数?
    • 是的,它有效,并且在 Adsense 中获得了展示次数。
    • 您的 Flutter 网站需要多长时间才能获得批准?您的网站是否已经拥有大量流量?
    • 您的申请是如何获得批准的?我收到了“有价值的库存:无内容”违规作为响应。我猜那里的爬虫无法获取纯 JS 应用程序。
    • 我已经建立了 www.droidbiz.in Flutter 网站。我无法让我的颤振网站获得 AdSense 的批准。它给出了“有价值的库存:没有内容”。您是如何获得批准的?
    猜你喜欢
    • 1970-01-01
    • 2021-01-17
    • 1970-01-01
    • 1970-01-01
    • 2018-12-13
    • 1970-01-01
    • 1970-01-01
    • 2020-02-26
    • 2013-12-18
    相关资源
    最近更新 更多