diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ec69e0..141a76c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ Alle nennenswerten Änderungen an diesem Projekt. Format nach - (app) Version 0.6.0 (6), HP-Balken gegen `kTankMaxHp` ### Added +- (ads) AdMob App ID im Manifest, `google_mobile_ads`, `AdsService` mit Rewarded/Interstitial und Frequenz-Caps +- (ui) Rewarded-Testbutton; Interstitial nach Matchende (ab Match 4, jeder 2.) - (build) Release-Skript mit ABI-abhängigem Alignment-Check, native-debug-symbols.zip, AAB - (build) R8/ProGuard-Regeln, `key.properties`-Support mit Debug-Fallback - (store) Icon 512, Feature-Graphic 1024x500, 4 Geraete-Screenshots, `store/listing.md` diff --git a/app/android/app/src/main/AndroidManifest.xml b/app/android/app/src/main/AndroidManifest.xml index 87e2c7b..c7e4df1 100644 --- a/app/android/app/src/main/AndroidManifest.xml +++ b/app/android/app/src/main/AndroidManifest.xml @@ -1,8 +1,9 @@ + + + { int _seed = 42; late final ApiClient _api = ApiClient(baseUrl: _baseUrl); late final OfflineQueue _queue = OfflineQueue(); + late final AdsService _ads = AdsService(); late final MatchSession _session = MatchSession(client: _api, queue: _queue, deviceId: 'pending'); late IronArcGame _game = _buildGame(); @@ -47,10 +49,12 @@ class _MatchScreenState extends State { void initState() { super.initState(); _initSession(); + _ads.initialize(); } @override void dispose() { + _ads.dispose(); _api.close(); _session.dispose(); super.dispose(); @@ -84,6 +88,7 @@ class _MatchScreenState extends State { } else if (game.hud.value.isFinished) { _session.enqueueReplay(game.replayJson()); } + if (game.hud.value.isFinished) _ads.onMatchFinished(); }; return game; } @@ -112,6 +117,12 @@ class _MatchScreenState extends State { _toast('Replay läuft'); } + Future _showRewardedAd() async { + final reward = await _ads.showRewarded(); + if (!mounted) return; + _toast(reward == null ? 'Keine Anzeige verfügbar' : 'Belohnung: +$reward'); + } + Future _flushQueue() async { final validated = await _session.flushQueue(); if (mounted) _toast('$validated Replay(s) validiert'); @@ -193,6 +204,7 @@ class _MatchScreenState extends State { onOnline: _startOnline, onReplay: _playReplay, onFlush: _flushQueue, + onAd: _showRewardedAd, ), ), ), diff --git a/app/lib/src/ads/ads_service.dart b/app/lib/src/ads/ads_service.dart new file mode 100644 index 0000000..bdbebb7 --- /dev/null +++ b/app/lib/src/ads/ads_service.dart @@ -0,0 +1,139 @@ +import 'package:flutter/foundation.dart'; +import 'package:google_mobile_ads/google_mobile_ads.dart'; + +/// AdMob integration. +/// +/// The **application id** lives in `AndroidManifest.xml` +/// (`ca-app-pub-3909261635234286~8769927442`). +/// +/// Until real ad units exist, Google's official **test units** are used on +/// purpose: showing live ads during development produces invalid traffic and can +/// get the AdMob account suspended. +class AdsService { + /// Official Google test unit for rewarded video. + static const String rewardedUnitId = + 'ca-app-pub-3940256099942544/5224354917'; + + /// Official Google test unit for interstitials. + static const String interstitialUnitId = + 'ca-app-pub-3940256099942544/1033173712'; + + /// Never show an interstitial during the first matches (retention). + static const int skipFirstMatches = 3; + + /// After that, at most every second match. + static const int everyNthMatch = 2; + + RewardedAd? _rewarded; + InterstitialAd? _interstitial; + bool _initialized = false; + int _matchesFinished = 0; + + bool get isInitialized => _initialized; + bool get isRewardedReady => _rewarded != null; + int get matchesFinished => _matchesFinished; + + /// Initialises the SDK once and preloads both formats. + Future initialize() async { + if (_initialized) return; + await MobileAds.instance.initialize(); + _initialized = true; + debugPrint('ads: SDK initialised'); + _loadRewarded(); + _loadInterstitial(); + } + + void _loadRewarded() { + RewardedAd.load( + adUnitId: rewardedUnitId, + request: const AdRequest(), + rewardedAdLoadCallback: RewardedAdLoadCallback( + onAdLoaded: (ad) { + _rewarded = ad; + debugPrint('ads: rewarded ready'); + }, + onAdFailedToLoad: (error) { + _rewarded = null; + debugPrint('ads: rewarded failed (${error.code}) ${error.message}'); + }, + ), + ); + } + + void _loadInterstitial() { + InterstitialAd.load( + adUnitId: interstitialUnitId, + request: const AdRequest(), + adLoadCallback: InterstitialAdLoadCallback( + onAdLoaded: (ad) { + _interstitial = ad; + debugPrint('ads: interstitial ready'); + }, + onAdFailedToLoad: (error) { + _interstitial = null; + debugPrint('ads: interstitial failed (${error.code}) ${error.message}'); + }, + ), + ); + } + + /// Shows a rewarded video and returns the granted amount, or null if none was + /// available (the caller must not grant a reward in that case). + Future showRewarded() async { + final ad = _rewarded; + if (ad == null) { + _loadRewarded(); + return null; + } + _rewarded = null; + int? earned; + ad.fullScreenContentCallback = FullScreenContentCallback( + onAdDismissedFullScreenContent: (ad) { + ad.dispose(); + _loadRewarded(); + }, + onAdFailedToShowFullScreenContent: (ad, error) { + debugPrint('ads: rewarded show failed ${error.code}'); + ad.dispose(); + _loadRewarded(); + }, + ); + await ad.show(onUserEarnedReward: (ad, reward) { + earned = reward.amount.toInt(); + debugPrint('ads: reward ${reward.amount} ${reward.type}'); + }); + return earned; + } + + /// Called when a match ends; applies the frequency caps from the GDD. + void onMatchFinished() { + _matchesFinished++; + if (_matchesFinished <= skipFirstMatches) return; + if (_matchesFinished % everyNthMatch != 0) return; + final ad = _interstitial; + if (ad == null) { + _loadInterstitial(); + return; + } + _interstitial = null; + ad.fullScreenContentCallback = FullScreenContentCallback( + onAdDismissedFullScreenContent: (ad) { + ad.dispose(); + _loadInterstitial(); + }, + onAdFailedToShowFullScreenContent: (ad, error) { + debugPrint('ads: interstitial show failed ${error.code}'); + ad.dispose(); + _loadInterstitial(); + }, + ); + ad.show(); + } + + void dispose() { + _rewarded?.dispose(); + _interstitial?.dispose(); + _rewarded = null; + _interstitial = null; + } +} diff --git a/app/lib/src/ui/widgets.dart b/app/lib/src/ui/widgets.dart index 5fd5590..865e398 100644 --- a/app/lib/src/ui/widgets.dart +++ b/app/lib/src/ui/widgets.dart @@ -96,12 +96,14 @@ class Controls extends StatelessWidget { required this.onOnline, required this.onReplay, required this.onFlush, + required this.onAd, }); final MatchSession session; final VoidCallback onOnline; final VoidCallback onReplay; final VoidCallback onFlush; + final VoidCallback onAd; @override Widget build(BuildContext context) { @@ -115,6 +117,7 @@ class Controls extends StatelessWidget { label: session.queued > 0 ? 'Senden (${session.queued})' : 'Senden', onTap: onFlush, ), + _Action(icon: Icons.ondemand_video, label: 'Ad', onTap: onAd), ], ); } diff --git a/app/pubspec.lock b/app/pubspec.lock index aae8655..c31487e 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -112,6 +112,14 @@ packages: description: flutter source: sdk version: "0.0.0" + google_mobile_ads: + dependency: "direct main" + description: + name: google_mobile_ads + sha256: "439e018d73b47565d1cf21410e893a8f46d5fb95110c41c266a6fb78449d7106" + url: "https://pub.dev" + source: hosted + version: "9.2.0" http: dependency: "direct main" description: @@ -405,6 +413,38 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.2" + webview_flutter: + dependency: transitive + description: + name: webview_flutter + sha256: d53e1ccf5516f25017e3c9d44c39034db352d20fa34fe200674270242c2c5111 + url: "https://pub.dev" + source: hosted + version: "4.14.1" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + sha256: "4de8b3d1ff4ebe1bdb42e68a5e4f809194a3cb0117a8f495f590004f00da3964" + url: "https://pub.dev" + source: hosted + version: "4.14.1" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: "1221c1b12f5278791042f2ec2841743784cf25c5a644e23d6680e5d718824f04" + url: "https://pub.dev" + source: hosted + version: "2.15.1" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + sha256: acac45e0a8d7beb1d0805521f44842f406c46eb5a69410f53d935e3c62138afc + url: "https://pub.dev" + source: hosted + version: "3.27.2" xdg_directories: dependency: transitive description: @@ -415,4 +455,4 @@ packages: version: "1.1.0" sdks: dart: ">=3.13.4 <4.0.0" - flutter: ">=3.44.0" + flutter: ">=3.47.0" diff --git a/app/pubspec.yaml b/app/pubspec.yaml index eaf4e22..0aa5c02 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -38,6 +38,7 @@ dependencies: ffi: ^2.2.0 http: ^1.6.0 shared_preferences: ^2.5.6 + google_mobile_ads: ^9.2.0 dev_dependencies: flutter_test: diff --git a/docs/compliance-play-store.md b/docs/compliance-play-store.md index 4c03e1b..dca6e4b 100644 --- a/docs/compliance-play-store.md +++ b/docs/compliance-play-store.md @@ -38,7 +38,7 @@ Legende: `[ ]` offen · `[x]` erledigt · `[~]` teilweise/geplant mit Owner | Status | Feld | Antwort/Plan | |---|---|---| -| `[ ]` | Enthält Werbung | **Ja** (AdMob, Interstitial/Rewarded/Banner) | +| `[x]` | Enthält Werbung | **Ja** – AdMob SDK im Release-APK, App ID verifiziert | | `[ ]` | Zielgruppe | **13+**, **nicht** am Families-Programm teilnehmen | | `[ ]` | Altersfreigabe (IARC) | Erwartung: USK 12 / PEGI 12 (kompetitive Gewalt, keine realistischen Darstellungen, keine Sprache) | | `[ ]` | Datenschutzerklärung | URL öffentlich; deckt AdMob/GA4/Firebase, Device-/Ad-ID, Crash-Logs, ungefährer Standort aus IP | diff --git a/docs/decisions.md b/docs/decisions.md index 1e43d53..54c84d0 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -64,3 +64,18 @@ spaeter App Links/Domain-Verifizierung oder eine Play-Rueckfrage zur Namensherku (`adb uninstall com.ironarc.iron_arc`). **Verworfen:** `de.softwareapp-hb.ironarc` (Bindestrich ist technisch ungueltig). + +--- + +## D5 — AdMob: Test-Units bis echte Unit-IDs vorliegen (2026-10-24) + +**Entscheidung:** Die App enthaelt die echte AdMob **App ID** +(`ca-app-pub-3909261635234286~8769927442`), zeigt aber ausschliesslich Googles +offizielle **Test-Units**. + +**Begruendung:** Live-Ads aus Entwicklungs-Builds erzeugen Invalid Traffic und koennen das +AdMob-Konto sperren. Test-Units liefern zuverlaessig Fill und sind dafuer vorgesehen. + +**Naechster Schritt:** echte Unit-IDs (Rewarded, Interstitial, ggf. Banner) vom Auftraggeber, +dann Ersatz der Konstanten in `app/lib/src/ads/ads_service.dart` — **erst nach** implementiertem +UMP-Consent. diff --git a/docs/monetization.md b/docs/monetization.md index c963c56..959f4dc 100644 --- a/docs/monetization.md +++ b/docs/monetization.md @@ -100,6 +100,20 @@ nicht an der Technik. Jeder Test: mind. 7 Tage, eine Variable, Entscheidung nach ARPDAU **und** D7 (nie nur Umsatz). +## 7a. Umsetzungsstand (M7a, 2026-10-24) + +| Punkt | Wert | +|---|---| +| AdMob **App ID** | `ca-app-pub-3909261635234286~8769927442` (in `AndroidManifest.xml`, im Release-APK verifiziert) | +| Ad-Unit-IDs | Googles **Test-Units** (Rewarded `…/5224354917`, Interstitial `…/1033173712`) | +| SDK | `google_mobile_ads`, initialisiert beim App-Start | +| Frequenz-Caps | Interstitial erst ab Match 4, dann jeder 2. Match (`AdsService`) | +| Rewarded | Test-Button im UI, Belohnung wird quittiert | +| **Offen** | echte Ad-Unit-IDs, **UMP-Consent (Pflicht vor Live-Ads in der EU)**, „Remove Ads"-IAP | + +**Wichtig:** Live-Ads dürfen erst nach dem UMP-Consent-Flow (TCF v2.2) ausgeliefert werden. +Bis dahin bleiben die Test-Units aktiv; sie erzeugen keinen Invalid Traffic. + ## 8. Offene Punkte 1. Ads schon in MVP-1 (Test-IDs) oder erst M7? (siehe README, offene Entscheidungen) diff --git a/store/listing.md b/store/listing.md index 18c00cd..ef34ed1 100644 --- a/store/listing.md +++ b/store/listing.md @@ -5,7 +5,7 @@ | Paket | `de.softwareapp_hb.ironarc` | | Version | 0.6.0 (versionCode 6) | | Zielgruppe | 13+, **nicht** im Families-Programm | -| Enthält Werbung | Ja (ab M7 aktiv, aktuell noch keine Ad-SDKs im Build) | +| Enthält Werbung | Ja – AdMob SDK ist eingebaut (App ID `ca-app-pub-3909261635234286~8769927442`) | | In-App-Käufe | Ja (geplant ab M7) | ## Titel (max. 30 Zeichen)