13

Is there AdMob support for Flutter web? All libraries that I found are intended only for Android and IOS

Fariz Mamedow
  • 139
  • 2
  • 3

2 Answers2

5

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.

Admobe panel

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)

first created an html file 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:

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',
    ),
  );
}
Ali Azimoshan
  • 1,081
  • 11
  • 26
  • Is safe to show ads on iFrame? – Sheikh Shofiullah Jun 27 '22 at 03:01
  • 1
    Like this guy is saying, "AdSense can't see any content that is inside an Iframe. That means it would appear to them that you are displaying ads on pages without content." https://support.google.com/adsense/thread/149874717?hl=en&msgid=149905341 – Sheikh Shofiullah Jun 27 '22 at 03:03
1

firebase_admob is now deprecated in favour of google_mobile_ads and both of them do not support flutter web. However, you can use display ads on websites using Google Adsense.

You can create a blank web page and add ads and embed the flutter app in the HTML page.

Ref:

Google Adsense

Embed flutter App in website

Nishuthan S
  • 1,538
  • 3
  • 12
  • 30
  • I can't get adsense approval for my flutter website :( it says that there it is a blank website without content (actually its not) – trueToastedCode Nov 29 '22 at 11:14