SKAdNetwork
A class that validates advertiser-driven app installations.
可以在保证用户隐私的同时,衡量广告系列的成功程度。涉及到3个参与者:
-
Ad networks - 广告平台
注册并提供network ID Registering an Ad Network
提供经过签名的广告给展示广告的App Signing and Providing Ads.
接收被广告展示的App安装成功的postback
验证postback Verifying an Install Validation Postback.
-
Source apps - 展示广告的App
添加network ID到info.plist
显示经过ad network签名的广告
-
Advertised apps - 被广告展示的App
SKAdNetwork APIs are designed to maintain user privacy. Apps don't need to use App Tracking Transparency before calling SKAdNetwork APIs, and can call these APIs regardless of their tracking authorization status. For more information about privacy, see User Privacy and Data Use.
ATT - AppTrackingTransparency
IDFA - Identifier For Advertising
IDFA 存储在手机系统中,可被设备上的每个 APP 获取,因此可以打通不同 APP 之间的广告。这就相当于广告追踪,你所有的浏览历史都有可能会别的商家利用,给你推相同或相似的广告。
ATTrackingManager
open class func requestTrackingAuthorization(completionHandler completion: @escaping (ATTrackingManager.AuthorizationStatus) -> Void)
class var trackingAuthorizationStatus: ATTrackingManager.AuthorizationStatus
@available(iOS 14, *)
public enum AuthorizationStatus : UInt {
case notDetermined = 0
case restricted = 1
case denied = 2
case authorized = 3
}
1. SKStoreProductViewController -> loadProduct(withParameters:completionBlock:)
func loadProduct(withParametersparameters: [String : Any], completionBlockblock: ((Bool, Error?) -> Void)? = nil)
主要传递parameters包含SKStoreProductParameterITunesItemIdentifier,广告应用的商店ID。
其它参数:
// iTunes Store item identifier (NSNumber) of the product
@available(iOS 6.0, *)
public let SKStoreProductParameterITunesItemIdentifier: String
// SKU for the In-App Purchase product (NSString) to render at the top of the product page
@available(iOS 11.0, *)
public let SKStoreProductParameterProductIdentifier: String
// iTunes Store affiliate token (NSString)
@available(iOS 8.0, *)
public let SKStoreProductParameterAffiliateToken: String
// iTunes Store affiliate campaign token (NSString)
@available(iOS 8.0, *)
public let SKStoreProductParameterCampaignToken: String
// Analytics provider token (NSString)
@available(iOS 8.3, *)
public let SKStoreProductParameterProviderToken: String
// Advertising partner token (NSString)
@available(iOS 9.3, *)
public let SKStoreProductParameterAdvertisingPartnerToken: String
// Advertising network's cryptographic signature for the atribution params (NSString)
@available(iOS 11.3, *)
public let SKStoreProductParameterAdNetworkAttributionSignature: String
// Advertising network campaign identifier (NSNumber)
@available(iOS 11.3, *)
public let SKStoreProductParameterAdNetworkCampaignIdentifier: String
// Advertising network identifier (NSString)
@available(iOS 11.3, *)
public let SKStoreProductParameterAdNetworkIdentifier: String
// Random entropy value for security (NSUUID)
@available(iOS 11.3, *)
public let SKStoreProductParameterAdNetworkNonce: String
// Timestamp for this ad impression (NSNumber)
@available(iOS 11.3, *)
public let SKStoreProductParameterAdNetworkTimestamp: String
// App Store item identifier of the source app (NSNumber)
@available(iOS 14.0, *)
public let SKStoreProductParameterAdNetworkSourceAppStoreIdentifier: String
@available(iOS 14.0, *)
public let SKStoreProductParameterAdNetworkVersion: String
2. SKAdNetwork
-> registerAppForAdNetworkAttribution()
-> updateConversionValue(_ conversionValue: Int)
在广告主应用第一次调用registerAppForAdNetworkAttribution()后,会在24小时内的时间窗结束后,发送归因的postback给adnetwork。如果在这个时间窗内,调用了updateConversionValues(_:)则将install postback事件再次推迟24小时(会延迟1天到64天之间,且最多传64种转化)。根据Singular的demo,该值在0-63。
@available(iOS 11.3, *)
open class SKAdNetwork : NSObject {
// Participating apps should call this on launch to complete the install+open action associated with a product view
@available(iOS 11.3, *)
open class func registerAppForAdNetworkAttribution()
@available(iOS 14.0, *)
open class func updateConversionValue(_ conversionValue: Int)
}
AppsFlyer 解决方案:
新增ATT权限获取
func requestAppTrackingAuthorization() {
if #available(iOS 14.5, *) {
ATTrackingManager.requestTrackingAuthorization { (status) in
var permissionStatusStr = ""
switch status {
case .authorized:
permissionStatusStr = "authorized"
case .denied:
permissionStatusStr = "denied"
case .restricted:
permissionStatusStr = "restricted"
case .notDetermined:
permissionStatusStr = "notDetermined"
@unknown default:
permissionStatusStr = "unknown"
}
}
}
}
设置延迟方法
if #available(iOS 14.5, *) {
AppsFlyerLib.shared().waitForATTUserAuthorization(timeoutInterval: 60)
}
Other Tips
Build Phases -> Link Binary With Libraries -> optional