Data Fetching Guide for iOS

    Airbridge Device ID

    • Description: Airbridge Device ID

    • Data Type: NSString*

    • Example: "82a16ec9-a273-48b6-9bb2-017eab641109"

    123
    #import <AirBridge/AirBridge.h>
    
    AirBridge.deviceUUID;

    IDFA

    • Description: IDFA (Identifier for Advertisers)

    • Data Type: NSString*

    • Example: "82a16ec9-a273-48b6-9bb2-017eab641109"

    123
    #import <AdSupport/AdSupport.h>
    
    ASIdentifierManager.sharedManager.advertisingIdentifier.UUIDString;

    IDFV

    • Description: IDFV (Identifier for Vendor)

    • Data Type: NSString*

    • Example: "82a16ec9-a273-48b6-9bb2-017eab641109"

    1
    UIDevice.currentDevice.identifierForVendor.UUIDString;

    Limit Ad Tracking

    • Description: Limit Ad Tracking settings

    • Data Type: BOOL

    • Example: false

    123
    #import <AdSupport/AdSupport.h>
    
    ASIdentifierManager.sharedManager.advertisingTrackingEnabled;

    Device Model

    • Description: Device model name

    • Data Type: NSString*

    • Example: iPhone

    1
    UIDevice.currentDevice.localizedModel;

    Device Identifier

    • Description: Device identifier name

    • Data Type: NSString*

    • Example: iPhone9,3

    1234567
    #import <sys/utsname.h>
    
    struct utsname systemInfo;
    uname(&systemInfo);
            
    return [NSString stringWithCString:systemInfo.machine
                              encoding:NSUTF8StringEncoding];

    Device Manufacturer

    • Description: Device manufacturer

    • Data Type: NSString*

    • Example: Apple

    1
    @"Apple"

    OS Name

    • Description: OS name

    • Data Type: NSString*

    • Example: iOS

    1
    UIDevice.currentDevice.systemName;

    OS Version

    • Description: OS version

    • Data Type: NSString*

    • Example:  13.3

    1
    UIDevice.currentDevice.systemVersion;

    Locale

    • Description: Device locale

    • Data Type: NSString*

    • Example: ko-KR

    123456789101112131415161718192021222324252627282930313233343536373839
    + (NSString *)getSystemLocale {
        NSString* language = [#ClassName# getSystemLanguage];
        NSString* country = [#ClassName# getSystemCountry];
        
        if(language == nil || country == nil) {
            return nil;
        }
        
        return [NSString stringWithFormat:@"%@-%@", language, country];
    }
    
    + (NSString*) getSystemLanguage {
        NSArray* preferredLanguages = NSLocale.preferredLanguages;
        
        if (preferredLanguages.count < 1) {
            return nil;
        }
        
        NSString* languageSource = preferredLanguages[0];
        if (languageSource == nil) {
            return nil;
        }
        
        NSRange barIndex = [languageSource rangeOfString:@"-"];
        if (barIndex.location != NSNotFound) {
            languageSource = [languageSource substringToIndex:barIndex.location];
        }
        
        return languageSource;
    }
    
    + (NSString*) getSystemCountry {
        NSLocale* locale = NSLocale.autoupdatingCurrentLocale;
        if (locale == nil) {
            return nil;
        }
        
        return [locale objectForKey:NSLocaleCountryCode];
    }

    Timezone

    • Description: Device timezone

    • Data Type: NSString*

    • Example: US/Pacific

    1
    NSTimeZone.systemTimeZone.name;

    Orientation

    • Description: Device display orientation

    • Data Type: NSString*

    • Example: portrait

    12345
    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
    if (UIInterfaceOrientationIsLandscape(orientation))
        return @"landscape";
    else
        return @"portrait";

    Screen Density

    • Description: Device screen density

    • Data Type: NSString*

    • Example: 3.000

    1
    [NSString stringWithFormat:@"%.3f", UIScreen.mainScreen.scale];

    Screen Height

    • Description: Device screen height

    • Data Type: NSString*

    • Example: 667.0

    1
    [NSString stringWithFormat:@"%.f", UIScreen.mainScreen.bounds.size.height];

    Screen Width

    • Description: Device screen width

    • Data Type: NSString*

    • Example: 375.0

    1
    [NSString stringWithFormat:@"%.f", UIScreen.mainScreen.bounds.size.width];

    Network Carrier

    • Description: Network carrier information

    • Data Type: NSString*

    123456789101112
    #import <CoreTelephony/CTCarrier.h>
    #import <CoreTelephony/CTTelephonyNetworkInfo.h>
    
    CTTelephonyNetworkInfo* networkInfo = [[CTTelephonyNetworkInfo alloc] init];
    
    if (@available(iOS 12.1, *)) {
        NSDictionary<NSString*, CTCarrier*>* providers = [networkInfo serviceSubscriberCellularProviders];
        return providers.allValues.firstObject.carrierName;
    } else {
        CTCarrier* provider = [networkInfo subscriberCellularProvider];
        return provider.carrierName;
    }

    Cellular Status

    • Description: Check if the device is using cellular network.

    • Data Type: BOOL

    • Example: false

    1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
    #import <SystemConfiguration/SystemConfiguration.h>
    #import <netinet/in.h>
    
    + (BOOL) isCellular {
        return [#ClassName# getNetworkInfo] == CELLULAR;
    }
    
    typedef enum : NSInteger {
        WIFI,
        CELLULAR,
        NONE
    } ABNetwork;
    
    + (ABNetwork) getNetworkInfo {
        struct sockaddr_in zeroAddress;
        bzero(&zeroAddress, sizeof(zeroAddress));
        zeroAddress.sin_len = sizeof(zeroAddress);
        zeroAddress.sin_family = AF_INET;
        
        SCNetworkReachabilityRef reachability
            = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *) &zeroAddress);
        if (reachability == nil) {
            return NONE;
        }
        
        SCNetworkReachabilityFlags flags;
        if (!SCNetworkReachabilityGetFlags(reachability, &flags)) {
            return NONE;
        }
        
        if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) {
            return NONE;
        }
        
        if (((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0)
            && !(((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0 || (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)
                 && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0))
        {
            return NONE;
        }
        
        if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) {
            return CELLULAR;
        } else {
            return WIFI;
        }
    }

    WiFi Status

    • Description: Check if the device is using WiFi

    • Data Type: BOOL

    • Example: false

    1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
    #import <SystemConfiguration/SystemConfiguration.h>
    #import <netinet/in.h>
    
    + (BOOL) isWifi {
        return [#ClassName# getNetworkInfo] == WIFI;
    }
    
    typedef enum : NSInteger {
        WIFI,
        CELLULAR,
        NONE
    } ABNetwork;
    
    + (ABNetwork) getNetworkInfo {
        struct sockaddr_in zeroAddress;
        bzero(&zeroAddress, sizeof(zeroAddress));
        zeroAddress.sin_len = sizeof(zeroAddress);
        zeroAddress.sin_family = AF_INET;
        
        SCNetworkReachabilityRef reachability
            = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *) &zeroAddress);
        if (reachability == nil) {
            return NONE;
        }
        
        SCNetworkReachabilityFlags flags;
        if (!SCNetworkReachabilityGetFlags(reachability, &flags)) {
            return NONE;
        }
        
        if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) {
            return NONE;
        }
        
        if (((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0)
            && !(((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0 || (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)
                 && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0))
        {
            return NONE;
        }
        
        if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) {
            return CELLULAR;
        } else {
            return WIFI;
        }
    }

    Application Package Name

    • Description: Application package name

    • Data Type: NSString*

    • Example:  co.ab180.ablog

    1
    NSBundle.mainBundle.bundleIdentifier;

    Application Version

    • Description: Application version

    • Data Type: NSString*

    • Example: 1.1.15

    1
    [NSBundle.mainBundle.infoDictionary objectForKey:@"CFBundleShortVersionString"];

    Event Timestamp

    • Description: Event creation time

    • Data Type: NSNumber*

    • Example: 1581043739682

    1
    [NSNumber numberWithUnsignedLongLong:NSDate.date.timeIntervalSince1970 * 1000];

    Was this page helpful?

    Have any questions or suggestions?