Admob Flutter plugin that shows banner ads using native platform views.

Overview

Looking for Maintainers.

Unfortunately I haven't been able to keep up with demand for features and improvments. If you are interested in helping maintain this repo please create an issue requesting maintainer status. Or consider using the new google_mobile_ads by Google.

admob_flutter

Build Status version version GitHub stars GitHub forks GitHub issues

Demo

A Flutter plugin that uses native platform views to show Admob banner ads!

This plugin also has support for Interstitial and Reward ads.

Installation

  • Add this to your package's pubspec.yaml file:
dependencies:
  admob_flutter: "<LATEST_VERSION>"
  • Install it - You can install packages from the command line:
flutter pub get

Android Specific Setup

Update your AndroidManifest.xml

Add your AdMob App ID to your app's AndroidManifest.xml file by adding the <meta-data> tag shown below. You can find your App ID in the AdMob UI. For android:value insert your own AdMob App ID in quotes, as shown below.

You can use these test App ID's from Admob for development:

Android: ca-app-pub-3940256099942544~3347511713
iOS: ca-app-pub-3940256099942544~1458002511
<manifest>
  <application>
    <meta-data
      android:name="com.google.android.gms.ads.APPLICATION_ID"
      android:value="ca-app-pub-3940256099942544~3347511713"/>
  </application>
</manifest>

iOS Specific Setup

Update your Info.plist per Firebase instructions.

<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>

and add

<key>io.flutter.embedded_views_preview</key>
<true/>

Starting from Beta 6, you also need to display the App Tracking Transparency authorization request for accessing the IDFA, so you have to update your Info.plist to add the NSUserTrackingUsageDescription key with a custom message describing your usage. Below is an example description text:

<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>

See Prepare for iOS 14+ for more information. You also need to update your ios/Podfile by adding platform :ios, '9.0' at the very top of your file.

Initialize the plugin

First thing to do before attempting to show any ads is to initialize the plugin. You can do this in the earliest starting point of your app, your main function:

import 'package:admob_flutter/admob_flutter.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  // Initialize without device test ids.
  Admob.initialize();
  // Or add a list of test ids.
  // Admob.initialize(testDeviceIds: ['YOUR DEVICE ID']);
}

If you're using iOS, you may also need to request the tracking authorization in order to display personalized ads:

// Run this before displaying any ad.
await Admob.requestTrackingAuthorization();

Supported Platforms

  • 0.3.0 >= iOS
  • 0.2.0 >= AndroidX

Supported Admob features

  • Banner Ads
  • Interstitial Ads
  • Reward Ads
  • Native Ads (Coming soon)

Check out the repository Wiki for more info!

FAQ

  • Why doesn't the Admob Banner class have a dispose method?
    • TL;DR - It's called automatically for you. Longer reason see 94
  • failed to load ad : 3
    • TL;DR - Things are working correctly, Admob didn't give you an ad. If the app id + ad unit is new, give it 24/48 hours. See:161 stackoverflow
    • See all Admob codes
  • Ads are not loading
    • TL;DR - Make sure you have the correct combination of id's per platform. See:161
  • Objective-C based project cannot build
    • TL;DR - You have to enable swift support for your flutter project. See: stackoverflow and 123
  • How do I manage consentement for users in the European Economic Area?
    • Pass nonPersonalizedAds: true to the classes constructor (AdmobBanner, AdmobInterstitial and AdmobReward) in order to not display personalized ads for users who don't give their consent. A way to ask users for their consent is to use the plugin admob_consent. Please note that the new recommended is to use the brand new UMP SDK (Android, iOS).

Recipes

Pull Requests

I welcome and encourage all pull requests. Here are some basic rules to follow to ensure timely addition of your request:

  1. Match the document style as closely as possible.
  2. Please keep PR titles easy to read and descriptive of changes, this will make them easier to review/merge.
  3. Pull requests must be made against master branch for this repository.
  4. Check for existing issues first, before filing an issue.
  5. Check the project board, before filing an issue.
  6. Read the FAQ, before filing an issue.
  7. Have fun!
Comments
  • Banner is re-created/re-loaded with each Navigator push()/pop()

    Banner is re-created/re-loaded with each Navigator push()/pop()

    Banner is reloaded with each Navigator push()/pop(), both onBannerCreated and AdmobAdEvent.loaded are called even the banner is a child of a const StalessWidget, whose build() method isn't called. Admob guidelines does not recommend to refresh banner manually. Is it possible to avoid this behaviour?

    enhancement help wanted more info required 
    opened by kestasb 27
  • Not compatible with latest Firebase packages upgrade

    Not compatible with latest Firebase packages upgrade

    Hi

    i had updated to latest firebase_auth and firebase_storage packages and i am getting the following error on dependencies:[!] CocoaPods could not find compatible versions for pod "nanopb": In Podfile: admob_flutter (from .symlinks/plugins/admob_flutter/ios) was resolved to 0.3.4, which depends on FirebaseAnalytics (~> 6.1.3) was resolved to 6.1.3, which depends on nanopb (~> 0.3.901)

    firebase_auth (from `.symlinks/plugins/firebase_auth/ios`) was resolved to 0.18.0-1, which depends on
      Firebase/Auth (~> 6.26.0) was resolved to 6.26.0, which depends on
        FirebaseAuth (~> 6.5.3) was resolved to 6.5.3, which depends on
          FirebaseCore (~> 6.6) was resolved to 6.7.2, which depends on
            FirebaseCoreDiagnostics (~> 1.3) was resolved to 1.6.0, which depends on
              nanopb (~> 1.30906.0)
    

    Can you help with upgrading your plugin to match latest firebase versions

    Thanks much

    enhancement good first issue iOS 
    opened by pazhut 22
  • android app crashes after build and install

    android app crashes after build and install

    im using these plugins

    flutter_swiper : any
      firebase_auth: ^0.14.0+5
      flutter_facebook_login: ^2.0.1
      shared_preferences: any
      cloud_firestore: ^0.12.9+5
      fluttertoast: ^3.1.3  
      image_picker: ^0.6.1+3
      cached_network_image: ^1.1.1
      intl: ^0.15.8
      google_sign_in: any
      flutter_local_notifications: ^0.8.2
      firebase_messaging: ^5.1.6
      photo_view: ^0.4.2
      firebase_storage: ^3.0.6
      #image_picker_modern: ^0.4.12+1
      animated_text_kit: ^1.3.1
      permission: ^0.1.4 
    

    when i build after adding admob_flutter app crashes on start. also added in manifest.xml

    used latest version admob_flutter: ^0.3.3

    iOS Android Priority 
    opened by sampathkumar7 19
  • Need iOS help?

    Need iOS help?

    Hi @YoussefKababe,

    Awesome work on this plugin! I have an immediate need for banner and interstitial on Android and iOS. I'm newer to Flutter and am still researching PlatformViews however I have experience in iOS. Are you open to PR's?

    enhancement 
    opened by kmcgill88 19
  • why I can‘t use banner ad for ios

    why I can‘t use banner ad for ios

    0.3.3 it's work on android but not work on ios: {error: Request Error: Cannot find an ad network adapter for mediation., errorCode: 8} no matter using test banner id or my banner id

    but interstitial Ad is work on both.

    i add this on my plist.info:

    <key>io.flutter.embedded_views_preview</key>
    	<true/>
    <key>GADApplicationIdentifier</key>
    	<string>ca-app-pub-XXXXX</string>
    

    IDE : XCODE 11.2 BETA

    bug iOS 
    opened by sunjianan9900 18
  • The plugin `admob_flutter` uses a deprecated version of the Android embedding

    The plugin `admob_flutter` uses a deprecated version of the Android embedding

    when i put admob_flutter: ^2.0.0-nullsafety.1 in pubspec, and type on cmd flutter pub get this error occurs!

    The plugin admob_flutter uses a deprecated version of the Android embedding. To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of
    Flutter will remove these deprecated APIs.

    opened by mariamalbarghouti 17
  •   [!] CocoaPods could not find compatible versions for pod

    [!] CocoaPods could not find compatible versions for pod "GoogleAppMeasurement":

    I'm getting following error while using together with firebase_analytics.

        [!] CocoaPods could not find compatible versions for pod "GoogleAppMeasurement":
          In Podfile:
            admob_flutter (from `.symlinks/plugins/admob_flutter/ios`) was resolved to 1.0.0, which depends on
              Google-Mobile-Ads-SDK (~> 7.64) was resolved to 7.67.0, which depends on
                GoogleAppMeasurement (~> 6.0)
    
            firebase_analytics (from `.symlinks/plugins/firebase_analytics/ios`) was resolved to 8.1.2, which depends on
              Firebase/Analytics (= 8.0.0) was resolved to 8.0.0, which depends on
                Firebase/Core (= 8.0.0) was resolved to 8.0.0, which depends on
                  FirebaseAnalytics (~> 8.0.0) was resolved to 8.0.0, which depends on
                    FirebaseAnalytics/AdIdSupport (= 8.0.0) was resolved to 8.0.0, which depends on
                      GoogleAppMeasurement (= 8.0.0)
    
    opened by penguru 16
  • Pin iOS Podspec versions

    Pin iOS Podspec versions

    Pinning the iOS versions required for Admob to work. This will address, https://github.com/YoussefKababe/admob_flutter/issues/74, for the future. If users didn't update their pods (which apparently Flutter doesn't do for you) you could be stuck with an old version of the ad SDK, hence it doesn't know about the new functionality.

    🚀

    enhancement iOS 
    opened by kmcgill88 16
  • After upgrading to flutter 3,i can't build my app this error message keep coming up

    After upgrading to flutter 3,i can't build my app this error message keep coming up

    /Users/pc/development/flutter/.pub-cache/hosted/pub.dartlang.org/admob_flutter-2.0.0/android/src/main/kotlin/com/shatsy/admobflutter/AdmobBannerFactory.kt: (9, 1): Class 'AdmobBannerFactory' is not abstract and does not implement abstract base class member public abstract fun create(p0: Context?, p1: Int, p2: Any?): PlatformView defined in io.flutter.plugin.platform.PlatformViewFactory e: /Users/pc/development/flutter/.pub-cache/hosted/pub.dartlang.org/admob_flutter-2.0.0/android/src/main/kotlin/com/shatsy/admobflutter/AdmobBannerFactory.kt: (10, 3): 'create' overrides nothing e: /Users/pc/development/flutter/.pub-cache/hosted/pub.dartlang.org/admob_flutter-2.0.0/android/src/main/kotlin/com/shatsy/admobflutter/AdmobInterstitial.kt: (63, 29): Null can not be a value of a non-null type String e: /Users/pc/development/flutter/.pub-cache/hosted/pub.dartlang.org/admob_flutter-2.0.0/android/src/main/kotlin/com/shatsy/admobflutter/AdmobReward.kt: (66, 29): Null can not be a value of a non-null type String ../../../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/flare_flutter-3.0.2/lib/flare_render_box.dart:167:26: Warning: Operand of null-aware operation '?.' has type 'SchedulerBinding' which excludes null.

    opened by mohamedMesalm 13
  • Ad failed to load : 3

    Ad failed to load : 3

    Ads are not showing on my phone, but the emulator also shows in test mode. as the error code: Ad failed to load: 3 i'm also sure you did everything right

    opened by hsnbsst 12
  • 'admob_flutter/admob_flutter-Swift.h' file not found'

    'admob_flutter/admob_flutter-Swift.h' file not found'

    === BUILD TARGET firebase_messaging OF PROJECT Pods WITH CONFIGURATION Debug === /usr/local/flutter/.pub-cache/hosted/pub.dartlang.org/admob_flutter-0.3.1/ios/Classes/AdmobFlutterPlugin.m:20:9: fatal error: 'admob_flutter/admob_flutter-Swift.h' file not found #import <admob_flutter/admob_flutter-Swift.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.

    iOS 
    opened by jiharal 11
  • Crash Application when implement mediation

    Crash Application when implement mediation

    Hi, currently i want to implement admob mediation with uniti ads into my application. When i try to implement

    implementation 'com.unity3d.ads:unity-ads:4.0.0' implementation 'com.google.ads.mediation:unity:4.0.0.0'

    Then run application, it will be crashed cause: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/ads/reward/RewardedVideoAdListener;

    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.reward.RewardedVideoAdListener" on path...

    Please help!!

    opened by onstonboy 0
  • admob_flutter not found

    admob_flutter not found

    ios/Runner/GeneratedPluginRegistrant.m:12:9: fatal error: module 'admob_flutter' not found @import admob_flutter;~~~~~~~^~~~~~~~~~~~~1 error generated. note: Using new build system note: Planning note: Build preparation complete note: Building targets in dependency order configure: MacOs: Big Sur 11.6.2 flutter: 1.8.1/Dart:2.7.0 Xcode: 13.2.1 Cocoa pods: 1.11.2

    opened by mahmudulhasan766 0
  • Memory Leak Issue, Tested in Android 11

    Memory Leak Issue, Tested in Android 11

    Hi @kmcgill88, i use your package to show banner ads in my applications. When i check in the devtools, memory usage capacity becomes bigger when admob banner is displayed. Tested in profile mode.

    I think when the page is closed, these banner Ads don't really disappear from memory, they are still there, so there is a memory leak Screen Shot 2021-11-24 at 17 43 35

    opened by yusriltakeuchi 0
  • Display is broken after loading banner ad

    Display is broken after loading banner ad

    Display is broken after loading banner ad!

    enter image description here

    enter image description here

    #flutter doctor -v

    `[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19042.867], locale tr-TR) • Flutter version 2.2.3 at C:\src\flutter • Framework revision f4abaa0735 (2 weeks ago), 2021-07-01 12:46:11 -0700 • Engine revision 241c87ad80 • Dart version 2.13.4

    [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\Aksoyhlc\AppData\Local\Android\Sdk • Platform android-30, build-tools 30.0.3 • ANDROID_HOME = C:\Users\Aksoyhlc\AppData\Local\Android\Sdk • ANDROID_SDK_ROOT = C:\Users\Aksoyhlc\AppData\Local\Android\Sdk • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174) • All Android licenses accepted.

    [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

    [√] Android Studio (version 4.1.0) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

    [√] VS Code (version 1.55.2) • VS Code at C:\Users\Aksoyhlc\AppData\Local\Programs\Microsoft VS Code • Flutter extension can be installed from: https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

    [√] Connected device (2 available) • sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.124

    • No issues found!` @kmcgill88

    opened by Aksoyhlc 0
Releases(3.0.0)
how to Integrating facebook audience network to flutter app for banner, interstitial, rewarded, native and native banner

fb_ads_flutter_12 A new Flutter project. Getting Started Watch the complite tutorial for integrating Facebook ads into the Flutter app in our Youtube

null 4 Nov 26, 2022
Easy-to-make native ads in flutter using AdMOB SDK.

native_admob_flutter Easy-to-make ads in Flutter with Google's AdMob SDK. English | Português Get started To get started with Native Ads for Flutter,

Bruno D'Luka 81 Dec 12, 2022
Google mobile ads applovin - AppLovin mediation plugin for Google Mobile Ads (Flutter).

AppLovin mediation plugin for Google Mobile Ads Flutter Google Mobile Ads Flutter mediation plugin for AppLovin. Use this package as a library depende

Taeho Kim 1 Jul 5, 2022
Plugin to integrate Facebook Native Banner Ad

flutter_fbaudience_network Plugin to integrate Facebook Native Ad to Flutter application Warning: The plugin is based on Flutter PlatformView (Android

Duy Duong 8 May 13, 2020
Find The Latest trending and upcoming movies and tv shows with MovieDB app. The app contains all info about movies and tv shows. find similar movies or shows, Browse all genres, video trailers, backdrops, logos, and posters.

MovieDB App Features. Dynamic Theming Search Functionality Onboarding-Screen Select favourite movie Home Screen Tranding movie Movies different catego

Ansh rathod 80 Dec 12, 2022
Plugin to integrate native firebase admob to Flutter application

flutter_native_admob Plugin to integrate Firebase Native Admob to Flutter application Platform supported: iOS, Android Getting Started For help gettin

Duy Duong 63 Dec 21, 2022
Responsive Scaffold - On mobile it shows a list and pushes to details and on tablet it shows the List and the selected item. Maintainer: @rodydavis

responsive_scaffold View the online demo here! On mobile it shows a list and pushes to details and on tablet it shows the List and the selected item.

Flutter Community 346 Dec 2, 2022
Demo of web banner in Flutter

web_carousel How to implement a Web Banner the right way in Flutter. Screenshots Desk: Mobile: Medium Article Here is the Medium Article via the frien

Fred Grott 0 Mar 18, 2022
Display a smart banner on top of the screen of your Flutter Web application.

Smart Banner Display a smart banner on top of the screen of your Flutter Web application. Inspired by smart-app-banner and react-smartbanner Try the o

Guillaume Roux 8 Jul 10, 2023
dna, dart native access. A lightweight dart to native super channel plugin

dna, dart native access. A lightweight dart to native super channel plugin, You can use it to invoke any native code directly in contextual and chained dart code.

Assuner 14 Jul 11, 2022
📅 Customizable flutter calendar widget including day and week views

?? Customizable, animated calendar widget including day, week, and month views. Navigation Animation Callbacks Changing the VisibleDateRange Available

Jonas Wanke 276 Jan 1, 2023
A super powerful widget to help developers build complex views quickly and comfortably.

FSuper FSuper can help developers build complex views quickly and comfortably. It supports rich text, rounded corners, borders, pictures, small red do

Fliggy Mobile 481 Dec 29, 2022
A super powerful widget to help developers build complex views quickly and comfortably.

FSuper FSuper can help developers build complex views quickly and comfortably. It supports rich text, rounded corners, borders, pictures, small red do

Fliggy Mobile 481 Dec 29, 2022
react-native native module for In App Purchase.

Documentation Published in website. Announcement Version 8.0.0 is currently in release candidate. The module is completely rewritten with Kotlin and S

dooboolab 2.3k Dec 31, 2022
A Flutter App To Watch Anime Online With No Ads

Tako Play A Mobile App to Watch Anime With No ADS !! . Please Do not put Tako-Pl

Kaung Satt Hein 133 Dec 22, 2022
The lightweight and powerful wrapper library for Twitter Ads API written in Dart and Flutter 🐦

TODO: Put a short description of the package here that helps potential users know whether this package might be useful for them. Features TODO: List w

Twitter.dart 2 Aug 26, 2022
An easy way to add all google ads to your flutter app.

Google Ads An easy way to add all google ads to your flutter app. How to use it Add the google_mobile_ads package using flutter pub add google_mobile_

Yemeni Open Source 4 Sep 27, 2022
Mangato - An Android & IOS app to read manga on your phone without ads.

Mangato Read your favorite Japanese manga on Mangato including Attack on Titan, Fairy Tail, The Seven Deadly Sins, Fuuka, One Piece, and more. WARNING

Marouane 20 Nov 21, 2022