34
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

iOS14.5からIDFA対応しておかないとデフォルトでadvertisingIdentifierが取得できなくなります!

Last updated at Posted at 2021-02-18

iOS14.5からIDFA対応しておかないとデフォルトで取得できなくなります!!!

iOS14.4までの動作はこちら
https://qiita.com/rd0501/items/4cd65ac973cc2736908f

環境

iOS 14.5 Developer Beta 2, 14.4 (実機)
Xcode Version 12.5 beta 2 (12E5234g)

検証結果

OS isAdvertisingTrackingEnabled trackingAuthorizationStatus uuidString
iOS14.5 false notDetermined 00000000-0000-0000-0000-000000000000
iOS14.5 false denied 00000000-0000-0000-0000-000000000000
iOS14.5 false authorized 取得できた
iOS14.4 true notDetermined 取得できた
iOS14.4 true denied 00000000-0000-0000-0000-000000000000
iOS14.4 true authorized 取得できた
iOS14.4 false authorized 取得できた
iOS14.4 false denied 00000000-0000-0000-0000-000000000000

14.5以降の場合のみ許可を求めるのが一番コスパよさそう

備考

  • iOS14.5からisAdvertisingTrackingEnabledfalseになってました
  • iOS14.5の設定アプリからPrivacy > Tracking > Allow Apps to Request to Track をOFFにするとtrackingAuthorizationStatusがdefaultでdeniedになる(14.4と一緒)(アラートは出ない)
  • iOS14.5 でアラートが出ている状態で端末の電源を切るとdeniedになる(14.4と一緒)
  • simulatorでは問答無用で00000000-0000-0000-0000-000000000000になるので注意(14.4と一緒)
  • restricted はよくわかりませんでしたが denied と同じ扱いで良さそう?(14.4と一緒)

その他


    @available(iOS, introduced: 6, deprecated: 14, message: "This has been replaced by functionality in AppTrackingTransparency's ATTrackingManager class.")
    open var isAdvertisingTrackingEnabled: Bool { get }

isAdvertisingTrackingEnabledが非推奨になってて何してもfalseになるようになった
14.4まではtrueも返ってきてた気がします

コード

if #available(iOS 14, *) {
    print(ATTrackingManager.trackingAuthorizationStatus.rawValue)
    ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
        print(status.rawValue)
        print(ATTrackingManager.trackingAuthorizationStatus.rawValue)
        print(ASIdentifierManager.shared().isAdvertisingTrackingEnabled)
        print(ASIdentifierManager.shared().advertisingIdentifier)
    })
} else {
    // Fallback on earlier versions
}
print(ASIdentifierManager.shared().isAdvertisingTrackingEnabled)
print(ASIdentifierManager.shared().advertisingIdentifier)
34
21
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?