flutter - Flutter ADS:为什么插页式广告在测试模式下有效,但在 Play Market 中无效?
问题描述
在 Interstitials 的测试模式下一切正常,但是当我在 play market 中加载捆绑包时,广告不起作用。添加了广告块。
编码:
class AdmobHelper {
InterstitialAd _interstitialAd;
int num_of_attempt_load = 0;
static initialization() {
if (MobileAds.instance == null) {
MobileAds.instance.initialize();
}
}
void createInterad() {
InterstitialAd.load(
adUnitId: 'ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX',
request: AdRequest(),
adLoadCallback:
InterstitialAdLoadCallback(onAdLoaded: (InterstitialAd ad) {
_interstitialAd = ad;
num_of_attempt_load = 0;
}, onAdFailedToLoad: (LoadAdError error) {
print('InterstitialAs FAILED to LOAD:---------- $error');
// ignore: unnecessary_statements
num_of_attempt_load + 1;
_interstitialAd = null;
if (num_of_attempt_load <= 2) {
createInterad();
}
}),
);
}
void showInterad() {
if (_interstitialAd == null) {
return;
}
_interstitialAd.fullScreenContentCallback = FullScreenContentCallback(
onAdShowedFullScreenContent: (InterstitialAd ad) {
print("ad onAdshowedFullscreen");
}, onAdDismissedFullScreenContent: (InterstitialAd ad) {
print("ad Disposed");
ad.dispose();
}, onAdFailedToShowFullScreenContent: (InterstitialAd ad, AdError aderror) {
print("$ad OnAFAILED $aderror");
ad.dispose();
createInterad();
});
_interstitialAd.show();
_interstitialAd = null;
}
}
将标签添加到 AndoidManifest.xml
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-XXXXXXXXXXXXXX~XXXXXXXXX"/>
按钮本身调用广告
在测试模式下,按下按钮后,会打开一个测试广告
onTap: () async {
admobHelper.createInterad();
admobHelper.showInterad();
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => EpgChannelList(
filteredUsers[index],
filteredUsers[index])));
},
onLongPress: (){
admobHelper.createInterad();
admobHelper.showInterad();
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => EpgChannelList(
filteredUsers[index],
filteredUsers[index])));
},
解决方案
推荐阅读
- javascript - 如何从 DynamoDB 中获取玩家的排名?
- meteor - Meteor 1.7.0.5:调用 API 需要超过 40 秒的时间
- jenkins - 如何在詹金斯管道上发布 cppcheck 结果?
- reactjs - 我们不能只是改变状态..吗?有什么副作用。。?
- ruby-on-rails - 渲染部分并将其传递给对象时,如何将资产中的图像显示为背景图像
- ios - 为什么使用 CABasicAnimation() 沿 y 轴向下动画后 UIButton 不起作用?
- angular - Devextreme Crosshair 垂直线仅在悬停时显示
- c# - 覆盖接口方法但使用派生类的参数
- python - html解析器忽略特定标签,如链接和列表
- c# - 更新查询 C# SQL Server