【简介】
https://developer.apple.com/documentation/apptrackingtransparency/
【步骤】
1、
import AppTrackingTransparency
import AdSupport
/// adid
public var cn_Adid: String {
if #available(iOS 14.0, *) {
var str = ""
ATTrackingManager.requestTrackingAuthorization { (status) in
if status == .authorized {
str = ASIdentifierManager.shared().advertisingIdentifier.uuidString
}
if status == .denied {
str = "用户不允许获取adid"
}
}
return str
} else {
return ASIdentifierManager.shared().advertisingIdentifier.uuidString
}
}
2 、
3、
// 通用参数
public var basePara: [String: String] {
var token = ""
token = UserDefaultsManager.queryDataForString(UserDefaultsName.User_token)
let localVersion: String = (Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String) // 版本号
let localBuildVersion: String = (Bundle.main.infoDictionary!["CFBundleVersion"] as! String) // 构建号
let device_id = requestAdPermission()
return ["term": "ios", "token": token, "device_model": UIDevice.current.modelName, "device_system": UIDevice.current.systemVersion, "version": localVersion, "buildVersion": localBuildVersion, "versionCode": localVersion, "device_id": device_id]
}
网友评论