-
-
Notifications
You must be signed in to change notification settings - Fork 153
Installation
Kevin McGill edited this page May 21, 2020
·
3 revisions
Add this to your pubspec.yml dependencies:
admob_flutter: "^VERSION"
Add your AdMob App ID to your app's AndroidManifest.xml file by adding the 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 this test App ID 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/>
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();
// Add a list of test ids.
// Admob.initialize(testDeviceIds: ['YOUR DEVICE ID']);
}