Reputation: 822
I want to using keywords in google mobile ads but its not working. Ads showing but there is no related advertisement
static BannerAd createBannerAd() {
BannerAd ad = new BannerAd(
adUnitId: getBannerAdId,
size: AdSize.banner,
request: AdRequest(keywords: Constants.fuelKeywords),
listener: AdListener(
onAdLoaded: (Ad ad) => print('Ad loaded.'),
onAdFailedToLoad: (Ad ad, LoadAdError error) {
print('Ad failed to load: $error');
ad.dispose();
},
onAdOpened: (Ad ad) => print('Ad opened.'),
onAdClosed: (Ad ad) => print('Ad closed.'),
onApplicationExit: (Ad ad) => print('Left application.'),
),
);
return ad;
}
Upvotes: 2
Views: 889
Reputation: 632
You can add keywords like this.
import 'package:google_mobile_ads/google_mobile_ads.dart';
AdRequest request = AdRequest(
keywords: <String>[
'foo',
'bar',
'wallpaper',//add keyword here
],
contentUrl: 'URL',
nonPersonalizedAds: true,
);
final BannerAd myBanner = BannerAd(
adUnitId: 'ca-app-pub-3166882328175414/3480332744',
size: AdSize.banner,
request: request,
listener: BannerAdListener(
onAdLoaded: (Ad ad) {
print('$BannerAd loaded.');
},
onAdFailedToLoad: (Ad ad, LoadAdError error) {
print('$BannerAd failedToLoad: $error');
ad.dispose();
},
onAdOpened: (Ad ad) => print('$BannerAd onAdOpened.'),
onAdClosed: (Ad ad) => print('$BannerAd onAdClosed.'),
),
);
Upvotes: 1
Reputation: 822
As far as I know, the package doesn't support using keywords to better tailor ads. There are however settings to change ads that should be for kids as well as setting different maturity ratings for ads such as E, T, M, etc. in a similar way to how video games are rated.
Upvotes: 1