Skip to content

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

License

Notifications You must be signed in to change notification settings

ZhangPingFan/admob_flutter

 
 

Repository files navigation

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: "^1.0.0-beta.3"
  • 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/>

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

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
  • Ads are not loading
    • TL;DR - Make sure you have the correct combination of id's per platform. See:161

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. Have fun!

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 35.2%
  • Dart 34.0%
  • Kotlin 18.9%
  • Ruby 8.4%
  • Objective-C 3.5%