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:
@@ -138,16 +138,14 @@
|
|||||||
android:name="com.google.android.gms.car.application"
|
android:name="com.google.android.gms.car.application"
|
||||||
android:resource="@xml/automotive_app_desc" />
|
android:resource="@xml/automotive_app_desc" />
|
||||||
|
|
||||||
<!--
|
<!-- AdMob application id (iap-freemium-unlock). Real id, provisioned
|
||||||
AdMob application id (iap-freemium-unlock).
|
in the AdMob console. Safe to use in all build modes — this id
|
||||||
TODO: this is Google's OFFICIAL TEST app id
|
only initializes the SDK; it never serves an ad by itself, so it
|
||||||
(ca-app-pub-3940256099942544~3347511713) — swap for the real
|
carries none of the "don't tap your own ads" risk that ad unit
|
||||||
AdMob app id once provisioned in the AdMob console. Never ship
|
ids do. -->
|
||||||
the test id to production.
|
|
||||||
-->
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.google.android.gms.ads.APPLICATION_ID"
|
android:name="com.google.android.gms.ads.APPLICATION_ID"
|
||||||
android:value="ca-app-pub-3940256099942544~3347511713" />
|
android:value="ca-app-pub-6038935671414339~4085536467" />
|
||||||
</application>
|
</application>
|
||||||
<queries>
|
<queries>
|
||||||
<intent>
|
<intent>
|
||||||
|
|||||||
@@ -1,15 +1,30 @@
|
|||||||
import 'dart:async';
|
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';
|
import 'package:google_mobile_ads/google_mobile_ads.dart';
|
||||||
|
|
||||||
/// TODO(ads): official Google TEST ad unit ids — AdMob has not provisioned
|
/// Official Google TEST ad unit ids. ALWAYS used outside release builds —
|
||||||
/// real ones yet (design.md Open Questions). Swap these for the real banner
|
/// tapping your own real ad unit during development/testing is invalid
|
||||||
/// / interstitial unit ids once available; never ship the test ids to
|
/// traffic and AdMob suspends accounts for it, so this is not optional.
|
||||||
/// production.
|
|
||||||
const bannerAdUnitIdPrueba = 'ca-app-pub-3940256099942544/6300978111';
|
const bannerAdUnitIdPrueba = 'ca-app-pub-3940256099942544/6300978111';
|
||||||
const interstitialAdUnitIdPrueba = 'ca-app-pub-3940256099942544/1033173712';
|
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
|
/// Ads port + AdMob adapter (Design "Interfaces / Contracts", ADR-6): owns
|
||||||
/// the entitlement gate for both surfaces, the interstitial's session
|
/// the entitlement gate for both surfaces, the interstitial's session
|
||||||
/// frequency cap, and is the ONLY `google_mobile_ads` call site besides
|
/// frequency cap, and is the ONLY `google_mobile_ads` call site besides
|
||||||
@@ -80,7 +95,7 @@ class ServicioAnuncios {
|
|||||||
try {
|
try {
|
||||||
final cargaCompleter = Completer<InterstitialAd?>();
|
final cargaCompleter = Completer<InterstitialAd?>();
|
||||||
await InterstitialAd.load(
|
await InterstitialAd.load(
|
||||||
adUnitId: interstitialAdUnitIdPrueba,
|
adUnitId: interstitialAdUnitId,
|
||||||
request: const AdRequest(),
|
request: const AdRequest(),
|
||||||
adLoadCallback: InterstitialAdLoadCallback(
|
adLoadCallback: InterstitialAdLoadCallback(
|
||||||
onAdLoaded: (ad) {
|
onAdLoaded: (ad) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class _BannerAnuncioSuperiorState extends State<BannerAnuncioSuperior> {
|
|||||||
// load failure takes in production. Never throws out of this method.
|
// load failure takes in production. Never throws out of this method.
|
||||||
final anuncio = BannerAd(
|
final anuncio = BannerAd(
|
||||||
size: AdSize.banner,
|
size: AdSize.banner,
|
||||||
adUnitId: bannerAdUnitIdPrueba,
|
adUnitId: bannerAdUnitId,
|
||||||
request: const AdRequest(),
|
request: const AdRequest(),
|
||||||
listener: BannerAdListener(
|
listener: BannerAdListener(
|
||||||
onAdLoaded: (ad) {
|
onAdLoaded: (ad) {
|
||||||
|
|||||||
Reference in New Issue
Block a user