How to retrieve iPhone IDFA from API?

前端 未结 11 823
深忆病人
深忆病人 2020-12-12 14:37

I would like to get the device IDFA. How to get this info from iOS official API ?

11条回答
  •  难免孤独
    2020-12-12 14:55

    Get IDFA in Swift:

        import AdSupport
    
        ...
    
        let myIDFA: String?
        // Check if Advertising Tracking is Enabled
        if ASIdentifierManager.sharedManager().advertisingTrackingEnabled {
            // Set the IDFA
            myIDFA = ASIdentifierManager.sharedManager().advertisingIdentifier.UUIDString
        } else {
            myIDFA = nil
        }
    

提交回复
热议问题