app_tracking_transparency 패키지는 Apple의 앱 추적 투명성 프레임워크를 통해 iOS 앱이 사용자에게 추적 권한을 요청할 수 있도록 해주는 Flutter 플러그인입니다. 시스템 레벨의 승인 대화 상자를 표시하는 간단한 인터페이스를 제공하여 개발자가 Apple의 개인정보 보호 요구 사항을 준수할 수 있도록 합니다. 이 플러그인은 iOS와 원활하게 통합되며 사용자의 동의 상태를 적절히 처리합니다. iOS 기기에서 광고 또는 분석 목적의 데이터를 수집하는 앱에 필수적입니다.
사용 사례
iOS에서 추적에 대한 사용자 동의 요청
애플의 개인정보 보호 규정 준수
트래킹 권한이 필요한 광고 네트워크와의 통합
실시간으로 사용자 동의 상태 모니터링
개인정보 보호 준수 분석 활성화
주요 기능
네이티브 iOS 추적 허용 대화 상자 표시
iOS 플랫폼만 지원
권한 상태 추적을 위한 콜백 제공
Flutter 앱과의 간단한 통합
Apple의 앱 추적 투명성 지침을 따릅니다
적합한 대상
광고 서비스를 사용하는 iOS 전용 앱
애플의 개인정보 보호 정책 준수를 필요로 하는 개발자
제3자 분석 또는 광고 SDK와 통합된 앱
추적을 위한 사용자 동의 관리가 필요한 프로젝트
고려 사항
iOS 플랫폼에서만 사용 가능
앱 로직에서 사용자 응답을 올바르게 처리해야 합니다
안드로이드 기기에서 작동하지 않습니다
Apple의 AppTrackingTransparency 프레임워크와 함께 사용해야 합니다
모든 추적 활동에 대해 사용자 동의를 존중해야 합니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
app_tracking_transparency
This Flutter plugin allows you to display ios 14+ tracking authorization dialog and request permission to collect data. Collected data is crucial for ad networks (ie admob) to work efficiently on ios 14+ devices.
Introduction
Starting in iOS 14.0 App Tracking Transparency framework is available so we can present the app-tracking authorization request to the end user.
Starting in iOS 14.5, IDFA will be unavailable until an app calls the App Tracking Transparency framework to present the app-tracking authorization request to the end user. If an app does not present this request, the IDFA will automatically be zeroed out which may lead to a significant loss in ad revenue.
On iOS >=14.0 <14.5, tracking authorization request dialog isn't required in order to get IDFA. Keep in mind that, in those iOS versions, if you ask for it and the user rejects it you will lose access to IDFA (see tests).
This plugin lets you display App Tracking Transparency authorization request and ask for permission.
Usage
Step 1:
Make sure you update Info.plist file located in ios/Runner directory and add the NSUserTrackingUsageDescription key with a custom message describing your usage.
<key>NSUserTrackingUsageDescription</key><string>This identifier will be used to deliver personalized ads to you.</string>
Step 2:
Google recommends that you should be using Google Mobile Ads SDK 7.64.0 or higher. The Google Mobile Ads SDK supports conversion tracking using Apple's SKAdNetwork, which means Google is able to attribute an app install even when IDFA is unavailable. This is a crucial step if you want to maximize your ad revenue when IDFA is not available. To enable this functionality, you will need to update the SKAdNetworkItems key with an additional dictionary in your Info.plist, check them here.
Example
In this example, the tracking authorization dialog is requested from the Home widget of the application. You can initiate this request from any StatefulWidget in your app.
// Import packageimport'package:app_tracking_transparency/app_tracking_transparency.dart';
voidmain() {
runApp(MyApp());
}
classMyAppextendsStatefulWidget{
@override_MyAppStatecreateState() => _MyAppState();
}
class_MyAppStateextendsState<MyApp> {
@overridevoidinitState() {
super.initState();
// Show tracking authorization dialog and ask for permissionWidgetsFlutterBinding.ensureInitialized().addPostFrameCallback((_) async {
final status = awaitAppTrackingTransparency.requestTrackingAuthorization();
});
}
@overrideWidgetbuild(BuildContext context) {
...
}
}
Google (admob) recommends implementing an explainer message that appears to users immediately before the consent dialogue. For additional info on this topic please refer to this article: https://support.google.com/admob/answer/9997589?hl=en
// If the system can show an authorization request dialogif (awaitAppTrackingTransparency.trackingAuthorizationStatus ==
TrackingStatus.notDetermined) {
// Show a custom explainer dialog before the system dialogawaitshowCustomTrackingDialog(context);
// Wait for dialog popping animationawaitFuture.delayed(constDuration(milliseconds: 200));
// Request system's tracking authorization dialogawaitAppTrackingTransparency.requestTrackingAuthorization();
}
The explainer dialog must not contain a "Decide later" button. It should contain only a "Continue" button and the system dialog must be shown after the explainer dialog. See this issue for details.
You can also get advertising identifier after authorization. Until a user grants authorization, the UUID returned will be all zeros: 00000000-0000-0000-0000-000000000000. Also note, the advertisingIdentifier will be all zeros in the Simulator, regardless of the tracking authorization status.
final uuid = awaitAppTrackingTransparency.getAdvertisingIdentifier();
Notes
To use this plugin you should compile your project using XCode 12+ and run your app on an ios 14 + device.
Important Notice
IOS does not allow to display multiple native dialogs. If you try to open a native dialog when there is already a dialog on screen, previous dialog will be forcefully closed by the system. It's very common to show notification permission dialog on the first run of an ios application. If you both try to show a notification permission dialog and app tracking request dialog, one of the each will be cancelled. One way to handle this is using an explainer dialog before requesting tracking authorization. Please check the sample project for more on this. I highly recommend this approach.
Another way to get over this problem is postponing permission request until 2nd, or Nth run of the application. If you choose this way, please make sure that you inform app store reviewer that you postponed tracking request, or your submission may be rejected.
And finally; Always test on a real device with a fresh installed application.