Admob Flutter plugin that shows banner ads using native platform views.
434
stars
83
commits
Dart
primary language
Aug 12, 2024
updated
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.

A Flutter plugin that uses native platform views to show Admob banner ads!
This plugin also has support for Interstitial and Reward ads.
dependencies:
admob_flutter: "<LATEST_VERSION>"
flutter pub get
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>
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.
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();
0.3.0 >= iOS0.2.0 >= AndroidXnonPersonalizedAds: 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).I welcome and encourage all pull requests. Here are some basic rules to follow to ensure timely addition of your request:
master branch for this repository.Dart
42.5%
Swift
32.1%
Kotlin
19.2%
Ruby
3.1%
Objective-C
3.0%
Admob Flutter plugin that shows banner ads using native platform views.
434
stars
83
commits
Dart
primary language
Aug 12, 2024
updated
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.

A Flutter plugin that uses native platform views to show Admob banner ads!
This plugin also has support for Interstitial and Reward ads.
dependencies:
admob_flutter: "<LATEST_VERSION>"
flutter pub get
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>
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.
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();
0.3.0 >= iOS0.2.0 >= AndroidXnonPersonalizedAds: 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).I welcome and encourage all pull requests. Here are some basic rules to follow to ensure timely addition of your request:
master branch for this repository.Dart
42.5%
Swift
32.1%
Kotlin
19.2%
Ruby
3.1%
Objective-C
3.0%