Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions packages/firebase_admob/lib/firebase_admob.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class MobileAdTargetingInfo {
this.designedForFamilies,
this.childDirected,
this.testDevices,
this.requestAgent,
});

final List<String> keywords;
Expand All @@ -56,10 +55,11 @@ class MobileAdTargetingInfo {
final bool designedForFamilies;
final bool childDirected;
final List<String> testDevices;
final String requestAgent;

Map<String, dynamic> toJson() {
final Map<String, dynamic> json = <String, dynamic>{};
final Map<String, dynamic> json = <String, dynamic>{
'requestAgent': 'flutter-alpha',
};

if (keywords != null && keywords.isNotEmpty) {
assert(keywords.every((String s) => s != null && s.isNotEmpty));
Expand All @@ -76,8 +76,6 @@ class MobileAdTargetingInfo {
assert(testDevices.every((String s) => s != null && s.isNotEmpty));
json['testDevices'] = testDevices;
}
if (requestAgent != null && requestAgent.isNotEmpty)
json['requestAgent'] = requestAgent;

return json;
}
Expand All @@ -92,14 +90,19 @@ abstract class MobileAd {
static final Map<int, MobileAd> _allAds = <int, MobileAd>{};

/// Default constructor, used by subclasses.
MobileAd({@required this.unitId, this.targetingInfo, this.listener}) {
MobileAd(
{@required this.unitId,
MobileAdTargetingInfo targetingInfo,
this.listener})
: _targetingInfo = targetingInfo ?? const MobileAdTargetingInfo() {
assert(unitId != null && unitId.isNotEmpty);
assert(_allAds[id] == null);
_allAds[id] = this;
}

/// Optional targeting info per the native AdMob API.
final MobileAdTargetingInfo targetingInfo;
MobileAdTargetingInfo get targetingInfo => _targetingInfo;
final MobileAdTargetingInfo _targetingInfo;

/// Identifies the source of ads for your application.
///
Expand Down
4 changes: 2 additions & 2 deletions packages/firebase_admob/test/firebase_admob_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void main() {
isMethodCall('loadBannerAd', arguments: <String, dynamic>{
'id': id,
'unitId': bannerAdUnitId,
'targetingInfo': null,
'targetingInfo': <String, String>{'requestAgent': 'flutter-alpha'},
}),
isMethodCall('showAd', arguments: <String, dynamic>{
'id': id,
Expand All @@ -93,7 +93,7 @@ void main() {
isMethodCall('loadInterstitialAd', arguments: <String, dynamic>{
'id': id,
'unitId': interstitialAdUnitId,
'targetingInfo': null,
'targetingInfo': <String, String>{'requestAgent': 'flutter-alpha'},
}),
isMethodCall('showAd', arguments: <String, dynamic>{
'id': id,
Expand Down