【Flutter】ATT(Application Tracking Transparency)対応

## リジェクト内容

>May 3, 2021 at 3:38 AM
From Apple
5. 1.2 Legal: Privacy - Data Use and Sharing

>Guideline 5.1.2 - Legal - Privacy - Data Use and Sharing

>We noticed you do not use App Tracking Transparency to request the user's permission before tracking their activity across apps and websites. The app privacy information you provided in App Store Connect indicates you collect data in order to track the user, including Performance Data, Crash Data, Advertising Data, Product Interaction, and Other Diagnostic Data.

>Starting with iOS 14.5, apps on the App Store need to receive the user’s permission through the AppTrackingTransparency framework before collecting data used to track them. This requirement protects the privacy of App Store users.

>Next Steps

>Here are two ways to resolve this issue:

>- You can remove the tracking functionality from your app and update your app privacy information in App Store Connect.
- If you decide to continue tracking users, you must implement App Tracking Transparency and request permission before collecting data used to track the user or device.

>Resources

>- See Frequently Asked Questions about the new requirements for apps that track users.
- Learn more about designing appropriate permission requests.

>Bug Fix Submissions


>If this is a bug fix submission and you'd like to have it approved at this time, reply to this message in Resolution Center to let us know. You do not need to resubmit your app for us to proceed.

>Alternatively, if you'd like to resolve these issues now, please feel free to resubmit. Let us know if you have any questions about the issues we found in our review.

>You may appeal your app rejection if you believe this decision was made incorrectly. We also invite you to provide feedback on our review guidelines.


## ATT(Application Tracking Transparency)とは

>iOS 14.5、iPadOS 14.5、tvOS 14.5以降では、ユーザーをトラッキングしたり、ユーザーのデバイスの広告識別子にアクセスしたりする際には、AppTrackingTransparencyのフレームワークを通じてユーザーの許可を得る必要があります。トラッキングとは、自分のAppで収集したユーザーやデバイスに関するデータを、ターゲット広告や広告効果測定を目的として、他社のApp、Webサイト、またはオフラインのプロパティから収集されたユーザーやデバイスに関するデータに紐付ける行為を指します。また、ユーザーやデバイスに関するデータをデータブローカーに共有することもトラッキングに該当します。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/261934/224db362-9e28-6335-858d-f4717e312d0e.png)



## 対応方法

[app_tracking_transparency](https://pub.dev/packages/app_tracking_transparency)を利用します。

### 導入


```dart:pubspec.yaml
  app_tracking_transparency:
```

### info.plistにConfigの追加

```swift:info.plist
      <key>SKAdNetworkItems</key>
      <array>
        <dict>
          <key>SKAdNetworkIdentifier</key>
          <string>cstr6suwn9.skadnetwork</string>
        </dict>
      </array>
```

```swift:info.plist
    <key>NSUserTrackingUsageDescription</key>
    <string>パーソナライズされた広告の表示のために使用いたします。</string>

```

### ATTリクエスト用の関数作成

```dart
import 'package:app_tracking_transparency/app_tracking_transparency.dart';

//・・・省略

  Future<void> confirmATTStatus() async {
    final status = await AppTrackingTransparency.requestTrackingAuthorization();
    print('ATT Status = $status');
  }
```

## 実装結果

以下のように正しくダイアログが表示されました。

<img width="350" alt="ファイル名" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/261934/e6815ae3-97c5-ab9e-996c-4623398e6a3f.png">

## 参考文献

https://developer.apple.com/jp/app-store/user-privacy-and-data-use/

https://pub.dev/packages/app_tracking_transparency