ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [Objective-C] IDFA ์ˆ˜์ง‘์„ ์œ„ํ•œ App Tracking Transparency ํ”„๋ ˆ์ž„์›Œํฌ ์ถ”๊ฐ€
    ๐ŸŽ iOS/๊ฐœ๋ฐœ 2023. 2. 5. 20:13

    ๐Ÿ“Œ IDFA

    IDFA๋Š” Identifier for Advertising์˜ ์•ฝ์ž๋กœ, Apple์—์„œ ์‚ฌ์šฉ์ž ๊ธฐ๊ธฐ์— ํ• ๋‹นํ•œ ์ž„์˜์˜ ์‹๋ณ„์ž์ž…๋‹ˆ๋‹ค. (Android์˜ ADID์™€ ์˜๋ฏธํ•˜๋Š” ๋ฐ”๊ฐ€ ๊ฐ™์€ ๊ฐ’์ž…๋‹ˆ๋‹ค.) ๊ด‘๊ณ ์ฃผ๋Š” ์ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์‚ฌ์šฉ์ž์—๊ฒŒ ๋งž์ถคํ˜• ๊ด‘๊ณ ๋ฅผ ์ œ๊ณตํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

     

    ๊ธฐ์กด์—๋Š” ์ด IDFA๊ฐ’์„ ๊ทธ๋ƒฅ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์—ˆ์œผ๋‚˜, iOS 14+๋ถ€ํ„ฐ๋Š” AppTrackingTransparency ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ํ†ตํ•ด ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ์ถ”์  ๊ถŒํ•œ์„ ๋ฐ›์•„์™€์•ผ IDFA๊ฐ’์„ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

     


     

     

    ๐Ÿ“Œ App Tracking Transparency ํ”„๋ ˆ์ž„์›Œํฌ ์ถ”๊ฐ€

    โž€ info.plist

    NSUserTrackingUsageDescription ๊ถŒํ•œ ์š”์ฒญ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

     

     

    โž ํ”„๋กœ์ ํŠธ ํŒŒ์ผ > General > Frameworks, Libraries, and Embedded Content

    AppTrackingTransparency ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

     

     

    โž‚ ํ”„๋กœ์ ํŠธ ํŒŒ์ผ > Build Phase > Link Binary With Libraries

    AppTrackingTransparency ํ”„๋ ˆ์ž„์›Œํฌ์˜ Status๋ฅผ Optional๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค. iOS 14+ ํ™˜๊ฒฝ์—์„œ๋งŒ ๋™์ž‘์‹œํ‚ค๊ธฐ ์œ„ํ•ด์„œ์ž…๋‹ˆ๋‹ค.

     


     

    ๐Ÿ“Œ ์ฝ”๋“œ ์ž‘์„ฑ

    #import <AppTrackingTransparency/AppTrackingTransparency.h>
    
    -(void)requestIDFA {
        if (@available(iOS 14, *)) {
            // ์„ค์ • > ๊ฐœ์ธ์ •๋ณด ๋ณดํ˜ธ ๋ฐ ๋ณด์•ˆ > ์ถ”์  ์—์„œ
            // Switch๊ฐ€ ON ์ƒํƒœ์ผ ๋•Œ๋งŒ ๊ถŒํ•œ์š”์ฒญ ํŒ์—… ๋…ธ์ถœ๋จ
            // Switch๊ฐ€ OFF ์ƒํƒœ์ผ ๋•Œ๋Š” ๊ถŒํ•œ์š”์ฒญ ํŒ์—… ๋…ธ์ถœ X, ์ž๋™ denied๋กœ ์„ธํŒ…๋จ
            NSLog(@"ATT ์ถ”์  ๊ถŒํ•œ ์š”์ฒญ");
            [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
                switch (status) {
                    case ATTrackingManagerAuthorizationStatusAuthorized:
                        NSLog(@"ATT ํ—ˆ์šฉ");
                        break;
                    case ATTrackingManagerAuthorizationStatusDenied:
                        NSLog(@"ATT ๊ฑฐ๋ถ€");
                        break;
                    case ATTrackingManagerAuthorizationStatusRestricted:
                        NSLog(@"ATT ์ œํ•œ");
                        break;
                    case ATTrackingManagerAuthorizationStatusNotDetermined:
                        NSLog(@"ATT ๋ฏธ๊ฒฐ์ •");
                        break;
                    default:
                        break;
                }
            }];
        }
    }

    requestTrackingAuthorizationWithCompletionHandler๋ฅผ ํ†ตํ•ด ์‚ฌ์šฉ์ž๋กœ ํ•˜์—ฌ๊ธˆ ์ถ”์  ๊ถŒํ•œ์„ ์š”์ฒญํ•˜๋Š” ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋„์šฐ๊ณ , ์‚ฌ์šฉ์ž๊ฐ€ ์„ ํƒํ•œ ๊ฐ’์— ๋”ฐ๋ผ ํ•„์š”ํ•œ ์ฒ˜๋ฆฌ๋ฅผ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

     

     



    ๐Ÿ“Œ ์ฐธ๊ณ  +

    ์ƒ๊ธฐ ๊ถŒํ•œ์š”์ฒญ ์ฝ”๋“œ๋ฅผ ์„ค์ •ํ•˜์—ฌ๋„, ์„ค์ • - ๊ฐœ์ธ์ •๋ณด ๋ณดํ˜ธ ๋ฐ ๋ณด์•ˆ - ์ถ”์ ์˜ '์•ฑ์ด ์ถ”์ ์„ ์š”์ฒญํ•˜๋„๋ก ํ—ˆ์šฉ' ์Šค์œ„์น˜๊ฐ€ ON ์ƒํƒœ์ผ ๋•Œ๋งŒ ๊ถŒํ•œ์š”์ฒญ ํŒ์—…์ด ๋…ธ์ถœ๋ฉ๋‹ˆ๋‹ค. ๋งŒ์•ฝ ์ด ์Šค์œ„์น˜๊ฐ€ ์‚ฌ์ง„์ฒ˜๋Ÿผ OFF ์ƒํƒœ๋ผ๋ฉด ๊ถŒํ•œ์š”์ฒญ ํŒ์—…์ด ๋…ธ์ถœ๋˜์ง€ ์•Š๊ณ  ์ž๋™์œผ๋กœ ๊ถŒํ•œ์š”์ฒญ์ด denied๋กœ ์„ธํŒ…๋ฉ๋‹ˆ๋‹ค.

     

    ๊ทธ๋Ÿผ ์ด ์Šค์œ„์น˜์˜ ON/OFF ๊ฐ’์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์€ ์—†๋Š”๊ฐ€? > ํ˜„์žฌ๋กœ์„œ๋Š” ์—†์–ด๋ณด์ž…๋‹ˆ๋‹ค.

     

    ๋”ฐ๋ผ์„œ ํŽ˜์ด์Šค๋ถ, ํŠธ์œ„ํ„ฐ, ๋„ค์ด๋ฒ„, ๋ฉœ๋ก  ๋“ฑ ๋งŽ์€ ์•ฑ๋“ค์ด ์ด ์Šค์œ„์น˜ ๊ฐ’์ด OFF์ผ ๋•Œ๋Š” ์ถ”์ ๊ถŒํ•œ ๊ด€๋ จํ•ด์„œ๋Š” ์•„์˜ˆ ์‚ฌ์šฉ์ž๊ฐ€ ์‹ ๊ฒฝ์“ฐ์ง€ ์•Š๊ณ  ์•ฑ์„ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์•„๋ฌด๊ฒƒ๋„ ๋„์šฐ์ง€ ์•Š์œผ๋ฉฐ, ON์ผ ๋•Œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋„์šฐ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

     

     

    โž€ ์ƒ์„ธ์„ค๋ช… ํ›„ ๊ถŒํ•œ์š”์ฒญ ํ”„๋กฌํ”„ํŠธ

    ํŠธ์œ„ํ„ฐ, ๋„ค์ด๋ฒ„, ํŽ˜์ด์Šค๋ถ ๋“ฑ์€ [๊ณ„์†ํ•˜๊ธฐ] / [๋„ค, ์ดํ•ดํ–ˆ์Šต๋‹ˆ๋‹ค.] ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๊ถŒํ•œ์š”์ฒญ ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋„์›๋‹ˆ๋‹ค. ๊ฐœ์ธ์ ์œผ๋กœ๋Š” ์ด๋Ÿฐ ๊ตฌ์„ฑ๋ฐฉ๋ฒ•์ด ์‚ฌ์šฉ์ž์—๊ฒŒ๋Š” ๊ฐ€์žฅ ์นœ์ ˆํ•œ ๋ฐฉ๋ฒ•์ธ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์ถ”์ ์ด๋ผ๋Š” ๋‹จ์–ด ์ž์ฒด๊ฐ€ ์‚ฌ์šฉ์ž๊ฐ€ ๊บผ๋ฆฌ๊ธฐ ์ข‹์€ ์–ด๊ฐ์ด๋ผ, ์ตœ๋Œ€ํ•œ ํ’€์–ด์„œ ์„ค๋ช…ํ•ด์ฃผ์–ด์•ผ ๊ฑฐ๋ถ€๊ฐ์„ ์กฐ๊ธˆ์ด๋‚˜๋งˆ ์ค„์ผ ์ˆ˜ ์žˆ์ง€ ์•Š์„๊นŒ ์‹ถ์Šต๋‹ˆ๋‹ค.

     

     

    โž ์ƒ์„ธ์„ค๋ช…๊ณผ ํ•จ๊ป˜ ๊ถŒํ•œ์š”์ฒญ ํ”„๋กฌํ”„ํŠธ

    ๋‹ค์Œ์นดํŽ˜๋Š” ์ƒ์„ธ์„ค๋ช…๊ณผ ์ถ”์ ๊ถŒํ•œ ํ”„๋กฌํ”„ํŠธ๋ฅผ ํ•จ๊ป˜ ๋„์›๋‹ˆ๋‹ค. ์ด๊ฒƒ๋„ ์„ค๋ช… ์ฝ์–ด๋ณด๋ฉด์„œ ๊ฒฐ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๋ฉด์—์„œ ์ข‹์€ ๋ฐฉ๋ฒ•์ธ ๋“ฏ!

     

     

    โž‚ ์ƒ์„ธ์„ค๋ช… ์—†์ด ๊ถŒํ•œ์š”์ฒญ ํ”„๋กฌํ”„ํŠธ

    ๋„ค์ด๋ฒ„์นดํŽ˜, ์ฟ ํŒก, ํ‹ฐ๋น™, ์›จ์ด๋ธŒ, ์—๋ธŒ๋ฆฌํƒ€์ž„ ๋“ฑ์€ ์„ค๋ช… ์—†์ด ์ถ”์ ๊ถŒํ•œ ํ”„๋กฌํ”„ํŠธ๋งŒ์„ ๋„์›๋‹ˆ๋‹ค. 

     


     

    ๐Ÿ“Œ ์ฐธ๊ณ  ++

    ์œ„์น˜๊ถŒํ•œ์ด๋‚˜ ํ‘ธ์‰ฌ๊ถŒํ•œ ๋“ฑ ๋‹ค๋ฅธ ๊ถŒํ•œ์˜ ํ”„๋กฌํ”„ํŠธ์— ์ด์–ด์„œ ๋ฐ”๋กœ ์ถ”์ ๊ถŒํ•œ ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋„์šฐ๋ ค๋ฉด, ์‚ฌ์šฉ์ž๊ฐ€ ์„ ํ–‰ ํ”„๋กฌํ”„ํŠธ์— ์‘๋‹ตํ•œ ์ดํ›„ ์‹คํ–‰๋˜๋Š” ํ•ธ๋“ค๋Ÿฌ์—์„œ ์ถ”์ ๊ถŒํ•œ์š”์ฒญ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ด ๋•Œ, ์ ์–ด๋„ 1์ดˆ ์ด์ƒ์˜ ์‹œ๊ฐ„ ์ง€์—ฐ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

    (์ฐธ๊ณ  ๋งํฌ: https://developer.apple.com/forums/thread/690607)

     

    ๊ถŒํ•œ ์š”์ฒญ์€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ƒํƒœ๊ฐ€ ํ™œ์„ฑ์ƒํƒœ(UIApplicationStateActive)์ธ ๊ฒฝ์šฐ์—๋งŒ ํ”„๋กฌํ”„ํŠธ๋˜๋Š”๋ฐ, Privacy ํ”„๋กฌํ”„ํŠธ๋Š” ํ”„๋กœ์„ธ์Šค ์™ธ์ ์œผ๋กœ ํ‘œ์‹œ๋˜๋ฉฐ, ํ‘œ์‹œ๋  ๋•Œ ์ผ์‹œ์ ์œผ๋กœ ์•ฑ์„ ๋น„ํ™œ์„ฑ์ƒํƒœ๋กœ ๋งŒ๋“ค๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๋‹ค๋ฅธ ๊ถŒํ•œ ์š”์ฒญ์ด ์‚ฌ์šฉ์ž ํ™•์ธ ๋ณด๋ฅ˜ ์ค‘์ธ ๊ฒฝ์šฐ ๋’ค๋”ฐ๋ผ์˜ค๋Š” ๊ถŒํ•œ ํ”„๋กฌํ”„ํŠธ๊ฐ€ ํ‘œ์‹œ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
    (์ฐธ๊ณ  ๋งํฌ: requestTrackingAuthorization ๊ณต์‹๋ฌธ์„œ)

     

    ์˜ˆ๋ฅผ ๋“ค์–ด ํ‘ธ์‰ฌ๊ถŒํ•œ ํ”„๋กฌํ”„ํŠธ๊ฐ€ ๋จผ์ € ํ‘œ์‹œ์ค‘์ผ ๋•Œ๋Š” ํ™œ์„ฑ์ƒํƒœ์—์„œ๋งŒ ํ‘œ์‹œ๋˜๋Š” ์ถ”์ ๊ถŒํ•œ ํ”„๋กฌํฌํŠธ๊ฐ€ ํ‘œ์‹œ์กฐ์ฐจ ๋˜์ง€ ์•Š๊ฒŒ ๋˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

     

    ํ‘ธ์‰ฌ๊ถŒํ•œ ํ—ˆ์šฉ์—ฌ๋ถ€ ์„ ํƒ์„ ๋งˆ์นœ ํ›„ ํ”„๋กฌํ”„ํŠธ๊ฐ€ ์‚ฌ๋ผ์ง€๊ณ  ๋น„ํ™œ์„ฑ์ƒํƒœ์—์„œ ๋ฒ—์–ด๋‚˜๊ธฐ๊นŒ์ง€์˜ ์‹œ๊ฐ„์„ ๋ฒŒ๊ธฐ ์œ„ํ•ด 1์ดˆ ์ •๋„์˜ ์‹œ๊ฐ„ ์ง€์—ฐ์„ ์ฃผ๋ฉด ํ›„ํ–‰ ํ”„๋กฌํ”„ํŠธ๋„ ์ •์ƒ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.

     

    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    center.delegate = self;
    [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound) completionHandler:^(BOOL granted, NSError * _Nullable error) {
    	if (!error) {
        	// ํ‘ธ์‰ฌ๊ถŒํ•œ ํ—ˆ์šฉ์—ฌ๋ถ€ ์„ ํƒ -> ์ถ”์ ๊ถŒํ•œ ํ—ˆ์šฉ์—ฌ๋ถ€ ์ˆœ์ฐจ์„ ํƒ์„ ์œ„ํ•ด DispatchAfter๋กœ 1์ดˆ ์ง€์—ฐ
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    		    [self requestIDFA];
            });
        }
    }

     

     

    ๋Œ“๊ธ€

Designed by Tistory.