You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: Update README with minimum gradle version (#23)
* Update README with minimum gradle plugin version.
* Update gradle version in example app.
* Update changelog.
* Update pubspec version.
* Address formatting issues for README.
* Fix formatting and add references to the codelab in the README.
Copy file name to clipboardExpand all lines: README.md
+44-38Lines changed: 44 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Get Started
1
+
# Google Mobile Ads for Flutter
2
2
3
3
This guide is intended for publishers who want to monetize a [Flutter](https://flutter.dev/) app.
4
4
@@ -8,6 +8,8 @@ The Google Mobile Ads SDK for Flutter currently supports loading and displaying
8
8
9
9
Note: This plugin also contains support for **[Google Ad Manager](https://admanager.google.com/home/)**. If you are interested in creating and loading an Ad with Ad Manager, you may follow the same prerequisites, platform setup, mobile ads SDK initialization steps outlined in this doc, and see [creating and loading an ad with Ad Manager](https://github.com/googleads/googleads-mobile-flutter#creating-and-loading-an-ad-with-ad-manager) for further instructions.
10
10
11
+
See also the [codelab for inline ads in Flutter](https://codelabs.developers.google.com/codelabs/admob-inline-ads-in-flutter#0) for a detailed guide on setting
12
+
inline banner and native ads.
11
13
12
14
## Prerequisites
13
15
@@ -16,6 +18,7 @@ Note: This plugin also contains support for **[Google Ad Manager](https://admana
16
18
* Android Studio 3.2 or higher
17
19
* Target Android API level 19 or higher
18
20
* Set `compileSdkVersion` to 28 or higher
21
+
* Android Gradle Plugin 4.1 or higher (this is the version supported by Flutter out of the box)
19
22
* Ios
20
23
* Latest version of Xcode with [enabled command-line tools](https://flutter.dev/docs/get-started/install/macos#install-xcode).
21
24
* Recommended: [Create an AdMob account](https://support.google.com/admob/answer/2784575) and [register an Android and/or iOS app](https://support.google.com/admob/answer/2773509)
@@ -31,8 +34,7 @@ Note: This plugin also contains support for **[Google Ad Manager](https://admana
31
34
### iOS
32
35
33
36
34
-
####
35
-
Update your Info.plist
37
+
#### Update your Info.plist
36
38
37
39
In your app's `ios/Runner/Info.plist` file, add a `GADApplicationIdentifier` key with a string value of your AdMob app ID ([identified in the AdMob UI](https://support.google.com/admob/answer/7356431)) as shown below:
38
40
@@ -122,14 +124,16 @@ The Mobile Ads SDK is now imported and you're ready to implement an ad. AdMob of
122
124
* Rewarded
123
125
* Ads that reward users for watching short videos and interacting with playable ads and surveys. Good for monetizing free-to-play users.
124
126
125
-
#Banner Ads
127
+
## Banner Ads
126
128
127
129
Banner ads occupy a spot within an app's layout, either at the top or bottom of the device screen. They stay on screen while users are interacting with the app, and can refresh automatically after a certain period of time.
128
130
129
131
This guide shows you how to integrate banner ads from AdMob into a Flutter app. In addition to code snippets and instructions, it also includes information about sizing banners properly and links to additional resources.
130
132
133
+
See also the [codelab for inline ads in Flutter](https://codelabs.developers.google.com/codelabs/admob-inline-ads-in-flutter#6) for a detailed guide on setting up banner ads.
131
134
132
-
## Always test with test ads
135
+
136
+
### Always test with test ads
133
137
134
138
When building and testing your apps, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account.
135
139
@@ -141,7 +145,7 @@ The easiest way to load test ads is to use our dedicated test ad unit ID for ban
141
145
It's been specially configured to return test ads for every request, and you're free to use it in your own apps while coding, testing, and debugging. Just make sure you replace it with your own ad unit ID before publishing your app.
142
146
143
147
144
-
## Instantiate a Banner Ad
148
+
###Instantiate a Banner Ad
145
149
146
150
A `BannerAd` requires an `adUnitId`, an `AdSize`, an `AdRequest`, and an `AdListener`. An example is shown below as well as more information on each parameter following.
147
151
@@ -155,7 +159,7 @@ final BannerAd myBanner = BannerAd(
155
159
);
156
160
```
157
161
158
-
### Banner Sizes
162
+
####Banner Sizes
159
163
160
164
The table below lists the standard banner sizes.
161
165
@@ -227,7 +231,7 @@ final AdSize adSize = AdSize(300, 50);
227
231
```
228
232
229
233
230
-
### Banner Ad Events
234
+
####Banner Ad Events
231
235
232
236
Through the use of `AdListener`, you can listen for lifecycle events, such as when an ad is closed or the user leaves the app. This example implements each method and logs a message to the console:
233
237
@@ -249,7 +253,7 @@ final AdListener listener = AdListener(
249
253
);
250
254
```
251
255
252
-
## Load Banner Ad
256
+
###Load Banner Ad
253
257
254
258
After a `BannerAd` is instantiated, `load()` must be called before it can be shown on the screen.
255
259
@@ -258,7 +262,7 @@ After a `BannerAd` is instantiated, `load()` must be called before it can be sho
258
262
myBanner.load();
259
263
```
260
264
261
-
## Display a Banner Ad
265
+
###Display a Banner Ad
262
266
263
267
To display a `BannerAd` as a widget, you must instantiate an `AdWidget` with a supported ad after calling `load()`. You can create the widget before calling `load()`, but `load()` must be called before adding it to the widget tree.
264
268
@@ -285,14 +289,14 @@ Once an Ad has called `load()`, it must call `dispose()` when access to it is no
285
289
That's it! Your app is now ready to display banner ads.
286
290
287
291
288
-
# Interstitial Ad
292
+
##Interstitial Ad
289
293
290
294
Interstitial ads are full-screen ads that cover the interface of their host app. They're typically displayed at natural transition points in the flow of an app, such as between activities or during the pause between levels in a game. When an app shows an interstitial ad, the user has the choice to either tap on the ad and continue to its destination or close it and return to the app.
291
295
292
296
This guide explains how to integrate interstitial ads into a Flutter app.
293
297
294
298
295
-
## Always test with test ads
299
+
###Always test with test ads
296
300
297
301
When building and testing your apps, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account.
298
302
@@ -305,7 +309,7 @@ The easiest way to load test ads is to use our dedicated test ad unit ID for ban
305
309
It's been specially configured to return test ads for every request, and you're free to use it in your own apps while coding, testing, and debugging. Just make sure you replace it with your own ad unit ID before publishing your app.
306
310
307
311
308
-
## Instantiate an Interstitial Ad
312
+
###Instantiate an Interstitial Ad
309
313
310
314
An `InterstitialAd` requires an `adUnitId`, an `AdRequest`, and an `AdListener`. An example is shown below as well as more information on each parameter following.
311
315
@@ -318,7 +322,7 @@ final InterstitialAd myInterstitial = InterstitialAd(
318
322
);
319
323
```
320
324
321
-
### Interstitial Ad Events
325
+
####Interstitial Ad Events
322
326
323
327
Through the use of `AdListener`, you can listen for lifecycle events, such as when an ad is closed or the user leaves the app. This example implements each method and logs a message to the console:
324
328
@@ -340,7 +344,7 @@ final AdListener listener = AdListener(
340
344
);
341
345
```
342
346
343
-
## Load Interstitial Ad
347
+
###Load Interstitial Ad
344
348
345
349
After an `InterstitialAd` is instantiated, `load()` must be called before it can be shown on the screen.
346
350
@@ -349,7 +353,7 @@ After an `InterstitialAd` is instantiated, `load()` must be called before it can
349
353
myInterstitial.load();
350
354
```
351
355
352
-
## Display an Interstitial Ad
356
+
###Display an Interstitial Ad
353
357
354
358
An `InterstitialAd` is displayed as an Overlay on top of all app content and is statically placed. Which means it can not be added to the Flutter widget tree. You can choose when to show the add by calling `show()` after the ad is loaded.
355
359
@@ -364,30 +368,32 @@ Once an ad has called `load()`, it must call `dispose()` when access to it is no
364
368
That's it! Your app is now ready to display interstitial ads.
365
369
366
370
367
-
## Next steps
371
+
###Next steps
368
372
369
373
370
374
371
375
* See [Interstitial best practices](https://www.youtube.com/watch?v=r2RgFD3Apyo&index=5&list=PLOU2XLYxmsIKX0pUJV3uqp6N3NeHwHh0c) and [interstitial ad guidance](https://support.google.com/admob/answer/6066980).
372
376
* Check out an [Interstitial ads case study](https://admob.google.com/home/resources/freaking-math-powers-revenue-increase-with-google-admob-support/).
373
377
* If you haven't already, create your own interstitial ad unit in the [AdMob UI](https://apps.admob.com/).
374
378
375
-
# Native Ads
379
+
##Native Ads
376
380
377
381
378
382
Native ads are ad assets that are presented to users via UI components that are native to the platform. They're shown using the same types of views with which you're already building your layouts, and can be formatted to match the visual design of the user experience in which they live. In coding terms, this means that when a native ad loads, your app receives a NativeAd object that contains its assets, and the app (rather than the Google Mobile Ads SDK) is then responsible for displaying them.
379
383
380
384
Broadly speaking, there are two parts to successfully implementing Native Ads: loading an ad via the SDK and displaying the ad content in your app. This guide is concerned with using the SDK to load native ads.
381
385
386
+
See also the [codelab for inline ads in Flutter](https://codelabs.developers.google.com/codelabs/admob-inline-ads-in-flutter#7) for a detailed guide on setting up native ads.
387
+
382
388
383
-
## Platform Setup
389
+
###Platform Setup
384
390
385
391
Native Ads are presented to users via UI components that are native to the platform. (e.g. A [View](https://developer.android.com/reference/android/view/View) on Android or a [UIView](https://developer.apple.com/documentation/uikit/uiview?language=objc) on iOS).
386
392
387
393
Since Native Ads require UI components native to a platform, this feature requires additional setup for Android and iOS:
388
394
389
395
390
-
### Android
396
+
####Android
391
397
392
398
The Android implementation of the Google Mobile Ads plugin requires a class that implements a NativeAdFactory. A `NativeAdFactory` contains a method that takes a [UnifiedNativeAd](https://developers.google.com/android/reference/com/google/android/gms/ads/formats/UnifiedNativeAd) and custom options and returns a [UnifiedNativeAdView](https://developers.google.com/android/reference/com/google/android/gms/ads/formats/UnifiedNativeAdView). The [UnifiedNativeAdView](https://developers.google.com/android/reference/com/google/android/gms/ads/formats/UnifiedNativeAdView) is what will be displayed in your app.
393
399
@@ -486,7 +492,7 @@ class NativeAdFactoryExample implements NativeAdFactory {
486
492
}
487
493
```
488
494
489
-
### iOS
495
+
####iOS
490
496
491
497
The iOS implementation of the Google Mobile Ads plugin requires a class that implements a `FLTNativeAdFactory`. A `FLTNativeAdFactory` contains a method that takes a `GADUnifiedNativeAd` and custom options and returns a `GADUnifiedNativeAdView`. The `GADUnifiedNativeAdView` is what will be displayed in your app.
492
498
@@ -586,7 +592,7 @@ When creating the `NativeAd` in Dart, the `factoryID` will need to match the one
586
592
@end
587
593
```
588
594
589
-
## Always test with test ads
595
+
### Always test with test ads
590
596
591
597
When building and testing your apps, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account.
592
598
@@ -598,7 +604,7 @@ The easiest way to load test ads is to use our dedicated test ad unit ID for ban
598
604
It's been specially configured to return test ads for every request, and you're free to use it in your own apps while coding, testing, and debugging. Just make sure you replace it with your own ad unit ID before publishing your app.
599
605
600
606
601
-
## Instantiate a Native Ad
607
+
### Instantiate a Native Ad
602
608
603
609
A `NativeAd` requires an `adUnitId`, a `factoryId`, an `AdRequest`, and an `AdListener`. An example is shown below as well as more information on each parameter following.
604
610
@@ -612,12 +618,12 @@ final NativeAd myNative = NativeAd(
612
618
);
613
619
```
614
620
615
-
### Factory Id
621
+
####Factory Id
616
622
617
623
The `factoryId` will need to match the one used to add the factory to `GoogleMobileAdsPlugin` on Android and/or the `FLTGoogleMobileAdsPlugin` on iOS. The same `factoryId` can be used by both platforms or each can have their own.
618
624
619
625
620
-
### Native Ad Events
626
+
####Native Ad Events
621
627
622
628
Through the use of `AdListener`, you can listen for lifecycle events, such as when an ad is closed or the user leaves the app. This example implements each method and logs a message to the console:
623
629
@@ -642,7 +648,7 @@ AdListener(
642
648
);
643
649
```
644
650
645
-
## Load Native Ad
651
+
###Load Native Ad
646
652
647
653
After a `NativeAd` is instantiated, `load()` must be called before it can be shown on the screen.
648
654
@@ -651,7 +657,7 @@ After a `NativeAd` is instantiated, `load()` must be called before it can be sho
651
657
myNative.load();
652
658
```
653
659
654
-
## Display a Native Ad
660
+
###Display a Native Ad
655
661
656
662
To display a `NativeAd` as a widget, you must instantiate an `AdWidget` with a supported ad after calling `load()`. You can create the widget before calling `load()`, but `load()` must be called before adding it to the widget tree.
657
663
@@ -676,19 +682,19 @@ Once an Ad has called `load()`, it must call `dispose()` when access to it is no
676
682
That's it! Your app is now ready to display native ads.
677
683
678
684
679
-
## Next steps
685
+
###Next steps
680
686
681
687
* Learn more about native ads in our [native ad playbook](https://admob.google.com/home/resources/native-ads-playbook/).
682
688
* See [native ads policies and guidelines](https://support.google.com/admob/answer/6329638) for implementing native ads.
683
689
* Check out some customer success stories: [Case study 1](https://admob.google.com/home/resources/alarmmon-achieves-higher-rpm-with-admob-triggered-native-ads/), [Case Study 2](https://admob.google.com/home/resources/linghit-limited-doubles-ad-revenue-with-admob-native-ads/)
684
690
685
691
686
-
# Rewarded Ads
692
+
##Rewarded Ads
687
693
688
694
Rewarded ads are ads that users have the option of interacting with [in exchange for in-app rewards](https://support.google.com/admob/answer/7313578). This guide shows you how to integrate rewarded ads from AdMob into a Flutter app.
689
695
690
696
691
-
## Always test with test ads
697
+
###Always test with test ads
692
698
693
699
When building and testing your apps, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account.
694
700
@@ -701,7 +707,7 @@ The easiest way to load test ads is to use our dedicated test ad unit ID for ban
701
707
It's been specially configured to return test ads for every request, and you're free to use it in your own apps while coding, testing, and debugging. Just make sure you replace it with your own ad unit ID before publishing your app.
702
708
703
709
704
-
## Instantiate a Rewarded Ad
710
+
###Instantiate a Rewarded Ad
705
711
706
712
A `RewardedAd` requires an `adUnitId`, an `AdRequest`, and an `AdListener` with the `onRewardedAdUserEarnedReward` callback implemented. An example is shown below as well as more information on each parameter following.
707
713
@@ -720,7 +726,7 @@ final RewardedAd myRewarded = RewardedAd(
720
726
```
721
727
722
728
723
-
### Rewarded Ad Events
729
+
####Rewarded Ad Events
724
730
725
731
Through the use of `AdListener`, you can listen for lifecycle events, such as when an ad is closed or the user leaves the app. This example implements each method and logs a message to the console:
726
732
@@ -749,7 +755,7 @@ AdListener(
749
755
Key Point: Make sure to implement the `onRewardedAdUserEarnedReward` event to
750
756
reward the user for watching an ad.
751
757
752
-
## Load Rewarded Ad
758
+
###Load Rewarded Ad
753
759
754
760
After a `RewardedAd` is instantiated, `load()` must be called before it can be shown on the screen.
755
761
@@ -758,7 +764,7 @@ After a `RewardedAd` is instantiated, `load()` must be called before it can be s
758
764
myRewarded.load();
759
765
```
760
766
761
-
## Display a RewardedAd
767
+
###Display a RewardedAd
762
768
763
769
A `RewardedAd` is displayed as an Overlay is displayed on top of all app content and is statically placed. Which means it can not be displayed this way can't be added to the Flutter widget tree. You can choose when to show the add by calling `show()` after the ad is loaded.
764
770
@@ -774,11 +780,11 @@ Once an ad has called `load()`, it must call `dispose()` when access to it is no
774
780
That's it! Your app is now ready to display rewarded ads.
775
781
776
782
777
-
# Targeting
783
+
##Targeting
778
784
779
785
The `RequestConfiguration` object collects the global configuration for every ad request and is applied by` MobileAds.instance.updateRequestConfiguration()`.
780
786
781
-
## Child-directed setting
787
+
###Child-directed setting
782
788
783
789
For purposes of the [Children's Online Privacy Protection Act (COPPA)](https://www.ftc.gov/tips-advice/business-center/privacy-and-security/children%27s-privacy), there is a setting called "tag for child-directed treatment."
784
790
@@ -797,7 +803,7 @@ final RequestConfiguration requestConfiguration = RequestConfiguration(
You can mark your ad requests to receive treatment for users in the European Economic Area (EEA) under the age of consent. This feature is designed to help facilitate compliance with the [General Data Protection Regulation (GDPR)](https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32016R0679). Note that you may have other legal obligations under GDPR. Please review the European Union’s guidance and consult with your own legal counsel. Please remember that Google's tools are designed to facilitate compliance and do not relieve any particular publisher of its obligations under the law. [Learn more about how the GDPR affects publishers](https://support.google.com/admob/answer/7666366).
The tags to enable the Child-directed setting and setTagForUnderAgeOfConsent should not both simultaneously be set to true. If they are, the child-directed setting takes precedence.
820
826
821
827
822
-
## Ad Content Filtering
828
+
###Ad Content Filtering
823
829
824
830
The setting can be set via` RequestConfiguration.maxAdContentRating()`:
0 commit comments