feat(iap): wire real AdMob app id, banner and interstitial units

App id always uses the real value (SDK init only, no ad-serving risk).
Banner/interstitial pick the real unit id in release builds and Google's
test unit id everywhere else, so debug/profile builds can never serve
(or accidentally tap) a real ad.
This commit is contained in:
2026-08-12 12:53:34 +02:00
parent d81fabbe27
commit 94f354a7c1
3 changed files with 28 additions and 15 deletions
+6 -8
View File
@@ -138,16 +138,14 @@
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<!--
AdMob application id (iap-freemium-unlock).
TODO: this is Google's OFFICIAL TEST app id
(ca-app-pub-3940256099942544~3347511713) — swap for the real
AdMob app id once provisioned in the AdMob console. Never ship
the test id to production.
-->
<!-- AdMob application id (iap-freemium-unlock). Real id, provisioned
in the AdMob console. Safe to use in all build modes — this id
only initializes the SDK; it never serves an ad by itself, so it
carries none of the "don't tap your own ads" risk that ad unit
ids do. -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713" />
android:value="ca-app-pub-6038935671414339~4085536467" />
</application>
<queries>
<intent>
+21 -6
View File
@@ -1,15 +1,30 @@
import 'dart:async';
import 'package:flutter/foundation.dart' show debugPrint;
import 'package:flutter/foundation.dart' show debugPrint, kReleaseMode;
import 'package:google_mobile_ads/google_mobile_ads.dart';
/// TODO(ads): official Google TEST ad unit ids — AdMob has not provisioned
/// real ones yet (design.md Open Questions). Swap these for the real banner
/// / interstitial unit ids once available; never ship the test ids to
/// production.
/// Official Google TEST ad unit ids. ALWAYS used outside release builds —
/// tapping your own real ad unit during development/testing is invalid
/// traffic and AdMob suspends accounts for it, so this is not optional.
const bannerAdUnitIdPrueba = 'ca-app-pub-3940256099942544/6300978111';
const interstitialAdUnitIdPrueba = 'ca-app-pub-3940256099942544/1033173712';
/// Real banner unit id, provisioned in the AdMob console (iap-freemium-unlock).
const _bannerAdUnitIdReal = 'ca-app-pub-6038935671414339/5658618378';
/// Real interstitial unit id, provisioned in the AdMob console (iap-freemium-unlock).
const _interstitialAdUnitIdReal = 'ca-app-pub-6038935671414339/4189478248';
/// Real id in release builds only; test id everywhere else (debug/profile,
/// including internal-testing-track builds run via `flutter run --release`
/// on a personal device — see the "never tap your own ads" note above).
const bannerAdUnitId = kReleaseMode
? _bannerAdUnitIdReal
: bannerAdUnitIdPrueba;
const interstitialAdUnitId = kReleaseMode
? _interstitialAdUnitIdReal
: interstitialAdUnitIdPrueba;
/// Ads port + AdMob adapter (Design "Interfaces / Contracts", ADR-6): owns
/// the entitlement gate for both surfaces, the interstitial's session
/// frequency cap, and is the ONLY `google_mobile_ads` call site besides
@@ -80,7 +95,7 @@ class ServicioAnuncios {
try {
final cargaCompleter = Completer<InterstitialAd?>();
await InterstitialAd.load(
adUnitId: interstitialAdUnitIdPrueba,
adUnitId: interstitialAdUnitId,
request: const AdRequest(),
adLoadCallback: InterstitialAdLoadCallback(
onAdLoaded: (ad) {
+1 -1
View File
@@ -40,7 +40,7 @@ class _BannerAnuncioSuperiorState extends State<BannerAnuncioSuperior> {
// load failure takes in production. Never throws out of this method.
final anuncio = BannerAd(
size: AdSize.banner,
adUnitId: bannerAdUnitIdPrueba,
adUnitId: bannerAdUnitId,
request: const AdRequest(),
listener: BannerAdListener(
onAdLoaded: (ad) {