「IOS 14 IDFA」修訂間的差異
		
		
		
		
		
		跳至導覽
		跳至搜尋
		
				
		
		
	
| imported>Wikiuser | imported>Wikiuser  | ||
| (未顯示同一使用者於中間所作的 5 次修訂) | |||
| 行 1: | 行 1: | ||
| == iOS 14+ == | == iOS 14+ == | ||
| 因應 iOS 14 Apple  | 因應 iOS 14 Apple 對於使用者[https://developer.apple.com/app-store/user-privacy-and-data-use/ 隱私權]的調整,取得 IDFA 必須透過 [https://developer.apple.com/documentation/apptrackingtransparency AppTrackingTransparency Framework] 取得使用者的授權,本文將說明 app 需要如何調整以取得 IDFA (取得IDFA 可以帶給使用者更好的廣告體驗)。 | ||
| == 請求 App Tracking Transparency 授權 == | == 請求 App Tracking Transparency 授權 == | ||
| 行 6: | 行 6: | ||
|      <key>NSUserTrackingUsageDescription</key> |      <key>NSUserTrackingUsageDescription</key> | ||
|      <string>Your data will be used to deliver personalized ads to you.</string> |      <string>Your data will be used to deliver personalized ads to you.</string> | ||
|      //此文案為參考用,實際的描述由各 app 自行定義 ex:  |      //此文案為參考用,實際的描述由各 app 自行定義 ex: 此資料將用來提供用戶更好的使用體驗 | ||
| 2. 實作顯示授權請求  <br> | 2. 實作顯示授權請求  <br> | ||
| 建議在第一次請求廣告之前向使用者取得授權,[https://developer.apple.com/documentation/apptrackingtransparency AppTrackingTransparency] 是 iOS 原生的 framework,需使用 Xcode 12 的版本才可以使用。<br> | |||
| '''需注意在 iOS 15 若是在 AppDelegate didFinishLaunchingWithOptions 內呼叫 requestTrackingAuthorization 將無法成功跳出詢問視窗,需要在 UIApplicationState 為 UIApplicationStateActive 時呼叫才能正常呈現詢問視窗,詳細請參考 [https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/3547037-requesttrackingauthorizationwith 官方文件]。'''  <br> | |||
| === Swift === | === Swift === | ||
|      import AppTrackingTransparency |      import AppTrackingTransparency | ||
| 行 27: | 行 28: | ||
|       }]; |       }]; | ||
|      } |      } | ||
| 範例圖示-紅匡內是info.plist內加入的文案內容<br> | |||
| [[檔案:Att alert.PNG | 300px]] | |||
於 2021年10月12日 (二) 07:58 的最新修訂
iOS 14+
因應 iOS 14 Apple 對於使用者隱私權的調整,取得 IDFA 必須透過 AppTrackingTransparency Framework 取得使用者的授權,本文將說明 app 需要如何調整以取得 IDFA (取得IDFA 可以帶給使用者更好的廣告體驗)。
請求 App Tracking Transparency 授權
1. 於 Info.plist 新增 NSUserTrackingUsageDescription key,及描述將如何使用此授權(清楚的描述可以提高使用者同意的意願)。
<key>NSUserTrackingUsageDescription</key> <string>Your data will be used to deliver personalized ads to you.</string> //此文案為參考用,實際的描述由各 app 自行定義 ex: 此資料將用來提供用戶更好的使用體驗
2. 實作顯示授權請求  
建議在第一次請求廣告之前向使用者取得授權,AppTrackingTransparency 是 iOS 原生的 framework,需使用 Xcode 12 的版本才可以使用。
需注意在 iOS 15 若是在 AppDelegate didFinishLaunchingWithOptions 內呼叫 requestTrackingAuthorization 將無法成功跳出詢問視窗,需要在 UIApplicationState 為 UIApplicationStateActive 時呼叫才能正常呈現詢問視窗,詳細請參考 官方文件。  
Swift
   import AppTrackingTransparency
   import AdSupport
   ...
   func requestIDFA() {
     ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
       // 詢問授權完成   
     })
   }
Objective-C
   #import <AppTrackingTransparency/AppTrackingTransparency.h>
   #import <AdSupport/AdSupport.h>
   ...
   - (void)requestIDFA {
      [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
       // 詢問授權完成      
    }];
   }