搜尋套件、儲存庫與 APP 分類

app_tracking_transparency 封面
套件詳情v2.0.7

app_tracking_transparency

此 Flutter 插件可讓您顯示 iOS 追蹤授權對話框並請求收集資料的權限。

iOS
近 30 天下載
46.2萬
喜歡數
481
Pub 分數
160

安裝套件

flutter pub add app_tracking_transparency

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

app_tracking_transparency 套件是 Flutter 插件,可讓 iOS 應用透過 Apple 的應用追蹤透明度架構請求使用者追蹤權限。它提供簡單介面來顯示系統層級授權對話方塊,讓開發者能符合 Apple 的隱私要求。此套件與 iOS 無縫整合,並確保正確處理使用者同意狀態。對於在 iOS 設備上收集資料用於廣告或分析用途的應用而言,這是不可或缺的。

適用情境

  • 請求使用者同意在iOS上進行追蹤
  • 遵守蘋果的隱私法規
  • 與需要追蹤權限的廣告網絡整合
  • 即時監控使用者同意狀態
  • 啟用符合隱私要求的分析

主要特色

  • 顯示原生 iOS 追蹤授權對話方塊
  • 僅支援iOS平台
  • 提供用於追蹤授權狀態的回呼
  • 與 Flutter 應用的簡單整合
  • 遵循 Apple 的應用追蹤透明度指南

適合對象

  • 僅限iOS的應用程式使用廣告服務
  • 需要符合蘋果隱私政策的開發者
  • 與第三方分析或廣告SDK整合的應用程式
  • 需要使用者同意管理追蹤的專案

使用建議

  • 僅在 iOS 平台上可用
  • 需要在應用邏輯中正確處理使用者回應
  • 無法在安卓設備上使用
  • 必須與 Apple 的 AppTrackingTransparency 框架一起使用
  • 用戶同意必須尊重所有追蹤活動

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

app_tracking_transparency

pub package

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 package
import 'package:app_tracking_transparency/app_tracking_transparency.dart';

void main() {
    runApp(MyApp());
}

class MyApp extends StatefulWidget {
    @override _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
    @override
    void  initState() {
        super.initState();
        // Show tracking authorization dialog and ask for permission
        WidgetsFlutterBinding.ensureInitialized().addPostFrameCallback((_) async { 
            final status = await AppTrackingTransparency.requestTrackingAuthorization();
        });     
    }

    @override
    Widget build(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 dialog
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();
}

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 = await AppTrackingTransparency.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.

所屬分類

原始碼儲存庫

使用此套件的專案