Data Fetching Guide for iOS

    Airbridge Device ID

    Device identifier by Airbridge. (example: 82A16EC9-A273-48B6-9BB2-017EAB641109)

    iOS SDK (v4)

    12345
    import Airbridge
    
    Airbridge.fetchDeviceUUID { deviceUUID in
    
    }

    iOS SDK (Previous)

    123
    import AirBridge
    
    AirBridge.deviceUUID

    Airbridge Generated ID

    Random UUID assigned by Airbridge upon app install on each device. (example: 82A16EC9-A273-48B6-9BB2-017EAB641109)

    iOS SDK (v4)

    12345
    import Airbridge
    
    Airbridge.fetchAirbridgeGeneratedUUID { airbridgeGeneratedUUID in
    
    }

    iOS SDK (Previous)

    12345
    import AirBridge
    
    AirBridge.fetchAirbridgeGeneratedUUID { uuid in
    
    }

    IDFA

    Advertising ID issued by Apple. (example: 82A16EC9-A273-48B6-9BB2-017EAB641109)

    123
    import AdSupport
    
    ASIdentifierManager.shared().advertisingIdentifier.uuidString

    IDFV

    Unique ID that publishers can use to identify which apps a specific user has installed. (example: 82A16EC9-A273-48B6-9BB2-017EAB641109)

    1
    UIDevice.current.identifierForVendor?.uuidString

    Limit Ad Tracking

    Device's Limit AD Tracking information. (example: true)

    123
    import AdSupport
    
    ASIdentifierManager.shared().isAdvertisingTrackingEnabled

    Device Model

    Device model name. (example: iPhone)

    1
    UIDevice.current.localizedModel

    Device Identifier

    Device identifier name. (example: iPhone9,3)

    1234
    var systemInfo = utsname()
    uname(&systemInfo)
            
    return String(cString: &systemInfo.machine.0, encoding: .utf8)

    Device Manufacturer

    Device manufacturer information. (example: Apple)

    1
    "Apple"

    OS Name

    Device OS name. (example: iOS)

    1
    UIDevice.current.systemName

    OS Version

    Device OS version. (example: 13.3)

    1
    UIDevice.current.systemVersion

    Locale

    Device locale settings. (example: ko-KR)

    1234567891011121314151617181920212223242526
    func getSystemLocale() -> String? {
        guard let language = getSystemLanguage() else { return nil }
        guard let country = getSystemCountry() else { return nil }
        
        return "\(language)-\(country)"
    }
    
    func getSystemLanguage() -> String? {
        let languages = Locale.preferredLanguages
        
        if languages.count < 1 {
            return nil
        }
        
        let languageSource = languages[0]
        
        guard let barIndex = languageSource.range(of: "-") else {
            return languageSource
        }
        
        return String(languageSource[..<barIndex.lowerBound])
    }
    
    func getSystemCountry() -> String? {
        return Locale.autoupdatingCurrent.regionCode
    }

    Timezone

    Device timezone settings. (example: US/Pacific)

    1
    TimeZone.current.description

    Orientation

    Device display orientation. Values will be either "portrait" or "landscape". (example: portrait)

    12345
    if UIDevice.current.orientation.isLandscape {
        return @"landscape"
    } else {
        return @"portrait"
    }

    Screen Density

    Device's screen density. (example: 3.000)

    1
    String(format: "%.3f", UIScreen.main.scale)

    Screen Width

    Device's actual width. (example: 375.0)

    1
    String(format: "%.f", UIScreen.main.bounds.size.width)

    Screen Height

    Device's actual height. (example: 667.0)

    1
    String(format: "%.f", UIScreen.main.bounds.size.height)

    Network Carrier

    Device network carrier information.

    1234567891011
    import CoreTelephony
    
    let info = CTTelephonyNetworkInfo()
    
    if #available(iOS 12.1, *) {
        let providers = info.serviceSubscriberCellularProviders
        return providers?.values.first?.carrierName
    } else {
        let provider = info.subscriberCellularProvider
        return provider?.carrierName
    }

    Cellular Status

    Device mobile data status. (example: true)

    12345678910111213141516171819202122232425262728293031323334353637383940414243
    import SystemConfiguration
    
    func isCellular() -> Bool {
        return network() == .cellular
    }
    
    enum Network {
        case wifi
        case cellular
        case none
    }
    
    func getNetworkInfo() -> Network {
        var zeroAddress = sockaddr()
        bzero(&zeroAddress, MemoryLayout.size(ofValue: zeroAddress))
        zeroAddress.sa_len = __uint8_t(MemoryLayout.size(ofValue: zeroAddress))
        zeroAddress.sa_family = sa_family_t(AF_INET)
    
        guard let reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, &zeroAddress) else {
            return .none
        }
    
        var flags = SCNetworkReachabilityFlags()
        if !SCNetworkReachabilityGetFlags(reachability, &flags) {
            return .none
        }
    
        if !flags.contains(.reachable) {
            return .none
        }
    
        if flags.contains(.connectionRequired)
            && !((flags.contains(.connectionOnDemand) || flags.contains(.connectionOnTraffic))
                && !flags.contains(.interventionRequired)) {
            return .none
        }
        
        if flags.contains(.isWWAN) {
            return .cellular
        } else {
            return .wifi
        }
    }

    WiFi Status

    Device wifi status. (example: true)

    12345678910111213141516171819202122232425262728293031323334353637383940414243
    import SystemConfiguration
    
    func isWifi() -> Bool {
        return network() == .wifi
    }
    
    enum Network {
        case wifi
        case cellular
        case none
    }
    
    func getNetworkInfo() -> Network {
        var zeroAddress = sockaddr()
        bzero(&zeroAddress, MemoryLayout.size(ofValue: zeroAddress))
        zeroAddress.sa_len = __uint8_t(MemoryLayout.size(ofValue: zeroAddress))
        zeroAddress.sa_family = sa_family_t(AF_INET)
    
        guard let reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, &zeroAddress) else {
            return .none
        }
    
        var flags = SCNetworkReachabilityFlags()
        if !SCNetworkReachabilityGetFlags(reachability, &flags) {
            return .none
        }
    
        if !flags.contains(.reachable) {
            return .none
        }
    
        if flags.contains(.connectionRequired)
            && !((flags.contains(.connectionOnDemand) || flags.contains(.connectionOnTraffic))
                && !flags.contains(.interventionRequired)) {
            return .none
        }
        
        if flags.contains(.isWWAN) {
            return .cellular
        } else {
            return .wifi
        }
    }

    Package Name

    Application package name. (example: co.ab180.ablog)

    1
    Bundle.main.bundleIdentifier

    Version

    Application version name. (example: 1.0.0)

    1
    Bundle.main.infoDictionary?["CFBundleShortVersionString"]

    Event Timestamp

    Timestamp(milliseconds) of when the event was sent. (example: 1581043739682)

    1
    UInt64(Date().timeIntervalSince1970 * 1000)

    このページは役に立ちましたか?

    ご質問やご提案はありますか?