iOS Guide

    개요

    iOS에서 에어브릿지 이벤트를 구성하는데 필요한 데이터를 수집하는 방법에 대해서 설명합니다.

    Device ID

    • 설명 : Airbridge 기기 식별자

    • 타입 : NSString*

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

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

    AirbridgeGeneratedUUID

    • 설명 : Airbridge에서 기기별로 인스톨시에 부여하는 랜덤한 UUID. UUID 버전4 포멧의 형태.

    • 타입 : NSString*

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

    12345
        #import <AirBridge/AirBridge.h>
    
        [AirBridge fetchAirbridgeGeneratedUUID:^(NSString * _Nonnull uuid) {
            
        }];

    IDFA

    • 설명 : 광고 식별자

    • 타입 : NSString*

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

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

    IFV

    • 설명 : IFV

    • 타입 : NSString*

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

    1
    UIDevice.currentDevice.identifierForVendor.UUIDString;

    Limit AD Tracking

    • 설명 : 광고 추적 제한 여부

    • 타입 : BOOL

    • 예시 : false

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

    Device Model

    • 설명 : 기기 모델명

    • 타입 : NSString*

    • 예시 : "iPhone"

    1
    UIDevice.currentDevice.localizedModel;

    Device Identifier

    • 설명 : 기기 식별명

    • 타입 : NSString*

    • 예시 : "iPhone9,3"

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

    Device Manufacturer

    • 설명 : 기기 제조사

    • 타입 : NSString*

    • 예시 : "Apple"

    1
    @"Apple"

    OS Name

    • 설명 : OS 이름

    • 타입 : NSString*

    • 예시 : "iOS"

    1
    UIDevice.currentDevice.systemName;

    OS Version

    • 설명 : OS 버전

    • 타입 : NSString*

    • 예시 : "13.3"

    1
    UIDevice.currentDevice.systemVersion;

    Locale

    • 설명 : 기기 Locale

    • 타입 : NSString*

    • 예시 : "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

    • 설명 : 기기 Timezone

    • 타입 : NSString*

    • 예시 : "Asia/Seoul"

    1
    NSTimeZone.systemTimeZone.name;

    Orientation

    • 설명 : 기기 방향

    • 타입 : NSString*

    • 예시 : "portrait"

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

    Screen Density

    • 설명 : 기기 화면 Density

    • 타입 : NSString*

    • 예시 : "3.000"

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

    Screen Height

    • 설명 : 기기 화면 세로 길이

    • 타입 : NSString*

    • 예시 : "667.0"

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

    Screen Width

    • 설명 : 기기 화면 가로 길이

    • 타입 : NSString*

    • 예시 : "375.0"

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

    Network Carrier

    • 설명 : 네트워크 사업자 정보

    • 타입 : 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

    • 설명 : 데이터 사용 여부

    • 타입 : boolean

    • 예시 : 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

    • 설명 : WiFi 사용 여부

    • 타입 : boolean

    • 예시 : 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;
        }
    }

    Package Name

    • 설명 : 어플리케이션 패키지

    • 타입 : NSString*

    • 예시 : "co.ab180.ablog"

    1
    NSBundle.mainBundle.bundleIdentifier;

    Version

    • 설명 : 어플리케이션 버전

    • 타입 : NSString*

    • 예시 : "1.1.15"

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

    Event Timestamp

    • 설명 : 이벤트 생성시간

    • 타입 : NSNumber*

    • 예시 : 1581043739682

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

    이 페이지가 도움이 되었나요?

    추가, 수정하면 좋을 내용이 있나요?