Open ghost opened 2 years ago
In addition popup seems not appear in production (release mode).
I've wrapped my MaterialApp with the following code :
import 'dart:io';
import 'package:app_tracking_transparency/app_tracking_transparency.dart';
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:visilab/services/logger.dart';
// Should we await for ATT before displaying app ? I notice that it took some times...
class MyAppTrackingTransparency extends StatefulWidget {
final Widget child;
const MyAppTrackingTransparency({final Key? key, required this.child}) : super(key: key);
@override
State<MyAppTrackingTransparency> createState() => _MyAppTrackingTransparency();
}
class _MyAppTrackingTransparency extends State<MyAppTrackingTransparency> {
@override
void initState() {
super.initState();
if (Platform.isIOS) {
// Can't show the dialog in initState, delaying initialization
WidgetsBinding.instance!.addPostFrameCallback((final _) {
initATT();
});
}
}
Future<void> initATT() async {
TrackingStatus status = TrackingStatus.notDetermined;
try {
status = await AppTrackingTransparency.trackingAuthorizationStatus;
//setState(() => _authStatus = '$status');
// If the system can show an authorization request dialog
if (status == TrackingStatus.notDetermined) {
status = await AppTrackingTransparency.requestTrackingAuthorization();
}
} catch (err, stack) {
LoggerCrashlytics.record(exception: err, stack: stack, reason: 'AppTrackingTransparency failed !');
} finally {
//setState(() => ready = true);
}
if (kDebugMode) print(status);
}
@override
Widget build(final BuildContext context) {
return widget.child;
}
}
I need to wrap initATT inside a Future.delayed to let him work in release, in debug popup is well displayed... Seems like I ask ATT 'too fast'...
Future<dynamic>.delayed(const Duration(seconds: 2), initATT);
Can you provide me some information about why this happen and what is the best way to implement ATT in Flutter app (where ?) :/
it happened to me also and it is not showing in release. did you find the problem?
Also happening to me. My app update got rejected on App Store. Need a fix asap.
I put a Future.delayed(Duration(seconds: 2)); before call ATT. App was approuved, but it is dirty !
in my case the permission was showing but they rejecting the app, i solved the problem by changing the privacy of the app , go to app privacy and in data types section click edit and select Identifiers (Device ID) and set this one as used for tracking purposes. and make sure that this is the only one selected as used for tracking. and i hope it will work with you if it is the same problem.
My app also got rejected because of that error.
I saw that ATTrackingManager has an async function. And I was hoping I could force wait for the function.
class func requestTrackingAuthorization() async -> ATTrackingManager.AuthorizationStatus But using an async function in the method channel on iOS-side makes the app crash and I couldn't find a way to solve that. Could be a limitation of the method channel.
AppTrackingTransparency.trackingAuthorizationStatus always return notDetermined if an other popup like notification permissions is visible.