I'm trying to implement Mopub into my Flutter project but I have some issues related to mopub_flutter package.
MopubAdManager class contains the IDs of Mopub stuff.
This is my initState:
void initState() {
try {
MoPub.init(MopubAdManager().publisherId, testMode: true).then((_) => {
loadRewardedAd(),
});
} catch (e) {
print('exception: ${e.toString()}');
}
super.initState();
This is the loadRewaredAd function
void loadRewardedAd() {
videoAd = MoPubRewardedVideoAd(MopubAdManager().rewardedAd, (result, args) {
setState(() {
var rewardedResult = '${result.toString()}____$args';
});
print('$result');
if (result == RewardedVideoAdResult.GRANT_REWARD) {
print('Grant reward: $args');
}
}, reloadOnClosed: true);
This is how I call the function inside a button with onPressed
RaisedButton(
child: Text('Show Video'),
onPressed: () async {
videoAd.load();
var result = await videoAd.isReady();
print('Is Ready $result');
if (result) {
videoAd.show();
}
},
),
Before touching the button, Mopub prints that line in console:
I/MoPub (30148): [com.mopub.network.TrackingRequest$1][onResponse] SDK Log - Successfully hit tracking endpoint: https://ads.mopub.com/m/open
After touching the Show Video button that appears in console:
V/AudioManager(30148): querySoundEffectsEnabled...
I/MoPub (30148): [com.mopub.mobileads.MoPubRewardedVideoManager][fetchAd] SDK Log - Loading rewarded ad request for ad unit 40825097a53247c5a91f9775d3f54298 with URL https://ads.mopub.com/m/ad?v=6&id=40825097a53247c5a91f9775d3f54298&nv=5.15.0&dn=HUAWEI%2CPOT-LX1%2CPOT-LX1&bundle=com.example.anket&z=%2B0300&o=p&cw=1080&ch=2259&w=1080&h=2340&sc=3.0&ct=2&av=1.0.0&abt=%7B%22tapjoy%22%3A%7B%22token%22%3A%221%22%7D%7D&ifa=mp_tmpl_advertising_id&dnt=mp_tmpl_do_not_track&tas=mp_tmpl_tas&mid=mp_tmpl_mopub_id&gdpr_applies=0&force_gdpr_applies=0¤t_consent_status=unknown&vv=4&vver=1.3.4-Mopub&mr=1
I/MoPub (30148): [com.mopub.network.AdLoader][fetchAd] Ad requesting from AdServer: https://ads.mopub.com/m/ad
I/MoPub (30148): {"vv":"4","nv":"5.15.0","mid":"e458ffd9-db59-4753-9878-c923a99ef3fc","dn":"HUAWEI,POT-LX1,POT-LX1","sc":"3.0","current_consent_status":"unknown","vver":"1.3.4-Mopub","id":"40825097a53247c5a91f9775d3f54298","bundle":"com.example.anket","gdpr_applies":"0","ch":"2259","ifa":"fe6b229f-fa21-4367-ac77-f8437ef7ebb6","mr":"1","tas":"authorized","h":"2340","force_gdpr_applies":"0","dnt":"0","o":"p","ct":"2","abt":"{\"tapjoy\":{\"token\":\"1\"}}","cw":"1080","av":"1.0.0","v":"6","w":"1080","z":"+0300"}
I/flutter (30148): Is Ready false
I/MoPub (30148): [com.mopub.network.MultiAdResponse][parseSingleAdResponse] Ad server responded with:
I/MoPub (30148): {"content":"","metadata":{"x-adtype":"clear","x-backfill":"clear","x-refreshtime":60}}
I/MoPub (30148): [com.mopub.network.AdLoader$1][onErrorResponse] Ad server responded with:
I/MoPub (30148): No ads found for ad unit.
I/flutter (30148): Flutter mopub rewarded method error
I/flutter (30148): RewardedVideoAdResult.ERROR
Other Ad types such as banner, interstitial shows the same error.
I have created the ad units and copied the Ids to the MopubAdManager class but yet no ads appear in the app. I have tested the test Ids they work perfectly.
Did I skip something?