From ae0fe2f75fd9e1b01f587b7606d1440d3ed2c365 Mon Sep 17 00:00:00 2001 From: Ivan Antunes Date: Mon, 2 Sep 2024 08:56:40 -0300 Subject: [PATCH] fix: added user tracking in ios --- ios/Podfile.lock | 6 ++++++ ios/Runner/Info.plist | 2 ++ lib/main.dart | 41 +++++++++++++++++++++++++++++++++++++++++ pubspec.lock | 8 ++++++++ pubspec.yaml | 3 ++- 5 files changed, 59 insertions(+), 1 deletion(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index c49f4258..b87aec11 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,4 +1,6 @@ PODS: + - app_tracking_transparency (0.0.1): + - Flutter - awesome_notifications (0.9.3): - Flutter - IosAwnCore (~> 0.9.3) @@ -235,6 +237,7 @@ PODS: - Flutter DEPENDENCIES: + - app_tracking_transparency (from `.symlinks/plugins/app_tracking_transparency/ios`) - awesome_notifications (from `.symlinks/plugins/awesome_notifications/ios`) - connectivity_plus (from `.symlinks/plugins/connectivity_plus/darwin`) - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) @@ -285,6 +288,8 @@ SPEC REPOS: - Toast EXTERNAL SOURCES: + app_tracking_transparency: + :path: ".symlinks/plugins/app_tracking_transparency/ios" awesome_notifications: :path: ".symlinks/plugins/awesome_notifications/ios" connectivity_plus: @@ -331,6 +336,7 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/webview_flutter_wkwebview/ios" SPEC CHECKSUMS: + app_tracking_transparency: e169b653478da7bb15a6c61209015378ca73e375 awesome_notifications: 66d28ab7174ca2823b04d275cb043e0a4a3eb9cf connectivity_plus: ddd7f30999e1faaef5967c23d5b6d503d10434db device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 28af65cb..50c7e216 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -91,5 +91,7 @@ UIViewControllerBasedStatusBarAppearance + NSUserTrackingUsageDescription + This identifier will be used for application crash diagnostics for internal development use only. diff --git a/lib/main.dart b/lib/main.dart index d20c77f5..cf5d100e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -15,12 +15,15 @@ import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:provider/provider.dart'; import 'package:responsive_framework/responsive_framework.dart'; +import 'package:app_tracking_transparency/app_tracking_transparency.dart'; final GlobalKey navigatorKey = GlobalKey(); Future initializeApp() async { WidgetsFlutterBinding.ensureInitialized(); + final status = await AppTrackingTransparency.requestTrackingAuthorization(); + await Firebase.initializeApp(); await FirebaseMessagingService().initNotifications(); await NotificationService.initialize(); @@ -69,12 +72,50 @@ class _AppState extends State { super.initState(); FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); + // WidgetsFlutterBinding.ensureInitialized().addPostFrameCallback((_) => initializeTracking()); _appStateNotifier = AppStateNotifier.instance; _router = createRouter(_appStateNotifier); Future.delayed(const Duration(milliseconds: 1000), () => setState(() => _appStateNotifier.stopShowingSplashImage())); } + // + // Future showCustomTrackingDialog(BuildContext context) async { + // await showDialog( + // context: context, + // builder: (context) => AlertDialog( + // title: const Text('Dear User'), + // content: const Text( + // 'We care about your privacy and data security. We keep this app free by showing ads. ' + // 'Can we continue to use your data to tailor ads for you?\n\nYou can change your choice anytime in the app settings. ' + // 'Our partners will collect data and use a unique identifier on your device to show you ads.', + // ), + // actions: [ + // TextButton( + // onPressed: () => Navigator.pop(context), + // child: const Text('Continue'), + // ), + // ], + // ), + // ); + // } + // + // Future initializeTracking() async { + // if (await AppTrackingTransparency.trackingAuthorizationStatus == + // TrackingStatus.notDetermined) { + // // Show a custom explainer dialog before the system dialog + // await showCustomTrackingDialog(context); + // // Wait for dialog popping animation + // await Future.delayed(const Duration(milliseconds: 200)); + // // Request system's tracking authorization dialog + // await AppTrackingTransparency.requestTrackingAuthorization(); + // } + // + // final uuid = await AppTrackingTransparency.getAdvertisingIdentifier(); + // log("UUID de Publicidade: $uuid"); + // } + + void setLocale(String language) { setState(() => _locale = createLocale(language)); diff --git a/pubspec.lock b/pubspec.lock index 90250518..7ed3b0b7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -9,6 +9,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.37" + app_tracking_transparency: + dependency: "direct main" + description: + name: app_tracking_transparency + sha256: "64d9745931e565790abdea91b518ac8dc3cebe6d0d0aaf7119343271b983259a" + url: "https://pub.dev" + source: hosted + version: "2.0.6" archive: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 2dcf4b82..4f66d5e2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A new Flutter project. publish_to: "none" -version: 1.0.0+5 +version: 1.0.0+6 environment: sdk: ">=3.0.0 <4.0.0" @@ -96,6 +96,7 @@ dependencies: permission_handler: ^11.3.1 firebase_crashlytics: ^4.0.1 awesome_notifications: ^0.9.3+1 + app_tracking_transparency: ^2.0.6 dependency_overrides: http: 1.2.1