Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[firebase_admob] Provide a default MobileAdTargetingInfo for RewardedVideoAd.load() #2245

Merged
merged 9 commits into from
Apr 24, 2020
3 changes: 2 additions & 1 deletion packages/firebase_admob/lib/firebase_admob.dart
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,8 @@ class RewardedVideoAd {

/// Loads a rewarded video ad using the provided ad unit ID.
Future<bool> load(
{@required String adUnitId, MobileAdTargetingInfo targetingInfo}) {
{@required String adUnitId,
MobileAdTargetingInfo targetingInfo = const MobileAdTargetingInfo()}) {
assert(adUnitId.isNotEmpty);
return _invokeBooleanMethod("loadRewardedVideoAd", <String, dynamic>{
'adUnitId': adUnitId,
Expand Down
29 changes: 29 additions & 0 deletions packages/firebase_admob/test/firebase_admob_e2e.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,35 @@ void main() {
);
});

testWidgets('Rewarded Video Ads', (WidgetTester tester) async {
bool adLoaded = false;

RewardedVideoAd.instance.listener =
(RewardedVideoAdEvent event, {int rewardAmount, String rewardType}) {
if (event == RewardedVideoAdEvent.loaded) adLoaded = true;
};

// Request without a targeting info
await RewardedVideoAd.instance.load(adUnitId: RewardedVideoAd.testAdUnitId);
await Future<void>.delayed(Duration(seconds: 10));
expect(adLoaded, isTrue);

adLoaded = false;

// Request with a targeting info
await RewardedVideoAd.instance.load(
adUnitId: RewardedVideoAd.testAdUnitId,
targetingInfo: MobileAdTargetingInfo(
keywords: <String>['foo', 'bar'],
contentUrl: 'http://foo.com/bar.html',
childDirected: true,
nonPersonalizedAds: true,
),
);
await Future<void>.delayed(Duration(seconds: 10));
expect(adLoaded, isTrue);
});

testWidgets('Native Ads', (WidgetTester tester) async {
bool adLoaded = false;

Expand Down