Auto-sync: 20260308_200000
This commit is contained in:
parent
d00bb4d3b1
commit
44d04cde64
3 changed files with 52 additions and 2 deletions
|
|
@ -1,9 +1,14 @@
|
|||
import 'dart:io'; // Aggiunto per il controllo Platform.isIOS
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
|
||||
// --- LIBRERIE META SDK E TRACCIAMENTO APPLE ---
|
||||
import 'package:app_tracking_transparency/app_tracking_transparency.dart';
|
||||
import 'package:facebook_app_events/facebook_app_events.dart';
|
||||
|
||||
// ⚠️ IMPORTANTE: Assicurati che questo file esista (generato da flutterfire configure)
|
||||
import 'firebase_options.dart';
|
||||
|
||||
|
|
@ -12,6 +17,9 @@ import 'scelta_lato.dart';
|
|||
import 'carro_attr.dart';
|
||||
import 'ps.dart';
|
||||
|
||||
// Istanza globale per tracciare gli eventi su Meta
|
||||
final facebookAppEvents = FacebookAppEvents();
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
|
|
@ -90,6 +98,35 @@ class _HomeScreenState extends State<HomeScreen> with RouteAware {
|
|||
super.initState();
|
||||
// Al primo avvio puliamo tutto
|
||||
_resetCompleto();
|
||||
|
||||
// --- NUOVO CODICE: TRACCIAMENTO APPLE ---
|
||||
// Lancia la richiesta di tracciamento appena la UI è pronta e visibile
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_richiediTracciamentoApple();
|
||||
});
|
||||
}
|
||||
|
||||
// --- NUOVO METODO PER IL POPUP APPLE E EVENTI META ---
|
||||
Future<void> _richiediTracciamentoApple() async {
|
||||
// Il popup serve ESCLUSIVAMENTE su iOS
|
||||
if (Platform.isIOS) {
|
||||
final TrackingStatus status = await AppTrackingTransparency.trackingAuthorizationStatus;
|
||||
|
||||
// Se l'utente non ha ancora fatto una scelta (è il primissimo avvio)
|
||||
if (status == TrackingStatus.notDetermined) {
|
||||
// Pausa vitale: Apple boccia le app se il popup appare prima che lo schermo sia ben visibile
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
|
||||
// Mostra il popup di sistema all'utente
|
||||
await AppTrackingTransparency.requestTrackingAuthorization();
|
||||
|
||||
// Logga l'evento della prima apertura su Facebook
|
||||
facebookAppEvents.logEvent(name: 'app_opened_first_time');
|
||||
}
|
||||
} else {
|
||||
// Su Android non c'è il blocco ATT, possiamo loggare liberamente l'apertura
|
||||
facebookAppEvents.logEvent(name: 'app_opened_android');
|
||||
}
|
||||
}
|
||||
|
||||
// Metodo centralizzato per reset e orientamento
|
||||
|
|
@ -125,8 +162,6 @@ class _HomeScreenState extends State<HomeScreen> with RouteAware {
|
|||
// 1. Sfondo Base (Mappa)
|
||||
const Positioned.fill(child: BackgroundImage()),
|
||||
|
||||
|
||||
|
||||
// Contenuto
|
||||
SafeArea(
|
||||
child: Center(
|
||||
|
|
@ -148,6 +183,10 @@ class _HomeScreenState extends State<HomeScreen> with RouteAware {
|
|||
onTap: () async {
|
||||
// Reset esplicito prima di iniziare
|
||||
await _resetCompleto();
|
||||
|
||||
// Logghiamo l'inizio di una compilazione su Meta
|
||||
facebookAppEvents.logEvent(name: 'cai_start_compilation');
|
||||
|
||||
if (context.mounted) {
|
||||
Navigator.push(
|
||||
context,
|
||||
|
|
@ -170,6 +209,7 @@ class _HomeScreenState extends State<HomeScreen> with RouteAware {
|
|||
icon: Icons.support_agent,
|
||||
baseColor: Colors.red.shade800,
|
||||
onTap: () {
|
||||
facebookAppEvents.logEvent(name: 'open_carro_attrezzi');
|
||||
Navigator.push(context, MaterialPageRoute(builder: (c) => const CarroAttrezziScreen()));
|
||||
},
|
||||
),
|
||||
|
|
@ -183,6 +223,7 @@ class _HomeScreenState extends State<HomeScreen> with RouteAware {
|
|||
icon: Icons.local_hospital_outlined,
|
||||
baseColor: Colors.green.shade800,
|
||||
onTap: () {
|
||||
facebookAppEvents.logEvent(name: 'open_pronto_soccorso');
|
||||
Navigator.push(context, MaterialPageRoute(builder: (c) => const ProntoSoccorsoScreen()));
|
||||
},
|
||||
),
|
||||
|
|
|
|||
|
|
@ -9,6 +9,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.59"
|
||||
app_tracking_transparency:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: app_tracking_transparency
|
||||
sha256: "1f71f4d8402552fbf8b191d4edab301f233c1af794878b7bc56c708470ffd74c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.6+1"
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ dependencies:
|
|||
flutter_localizations:
|
||||
sdk: flutter
|
||||
facebook_app_events: ^0.24.0
|
||||
app_tracking_transparency: ^2.0.6+1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
|
|||
Loading…
Reference in a new issue