简体   繁体   English

有AdMob支持Flutter web吗?

[英]Is there AdMob support for Flutter web?

Is there AdMob support for Flutter web?有AdMob支持Flutter web吗? All libraries that I found are intended only for Android and IOS我找到的所有库仅适用于 Android 和 IOS

As you can see in the image below, Google Admobe is not supported for the web so you can not use it for flutter web or other web frameworks.如下图所示,web 不支持 Google Admobe,因此您不能将其用于 flutter web 或其他 web 框架。

Admobe面板

On other hand, you can use adsense and set your ads for flutter web, and I find this solution for using Adsense as HTML(with IFrameElement)另一方面,您可以使用adsense并将广告设置为 flutter web,我找到将 Adsense 用作 HTML(使用 IFrameElement)的解决方案

first created an html file adview.html首先创建一个 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>

And then, an IFrameElement to make use of the HTML:然后,使用 HTML 的 IFrameElement:

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

firebase_admob is now deprecated in favour of google_mobile_ads and both of them do not support flutter web. firebase_admob现在已弃用,取而代之的是google_mobile_ads ,它们都不支持 flutter web。 However, you can use display ads on websites using Google Adsense.但是,您可以在使用 Google Adsense 的网站上使用展示广告。

You can create a blank web page and add ads and embed the flutter app in the HTML page.您可以创建一个空白的 web 页面并添加广告并在 HTML 页面中嵌入 flutter 应用程序。

Ref:参考:

Google Adsense 谷歌的AdSense

Embed flutter App in website 在网站中嵌入 flutter App

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM