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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user