앱에서 게재되는 광고에 대해 자세히 알 수 있도록 광고를 자체 GADAdMetadataDelegate로 설정하세요. 그런 다음 GADAdMetadataDelegate에서 adMetadataDidChange: 메서드를 구현하여 광고 메타데이터 변경사항을 수신 대기할 수 있습니다. 이 대리자가 호출되면 광고에서 adMetadata 속성을 확인합니다.
adMetadataDidChange:는 광고가 로드된 직후 또는 광고의 메타데이터가 로드된 후 비동기적으로 변경될 때 호출됩니다. 광고 메타데이터가 로드 시에 제공된다는 보장은 없으므로 광고의 메타데이터에 액세스하기 전에 이 콜백을 기다리는 것이 좋습니다.
다음은 보상형 광고의 광고 메타데이터를 가져오는 방법을 보여주는 코드 예입니다.
@interfaceViewController()<GADFullScreenContentDelegate,GADAdMetadataDelegate>
@end@implementationViewController-(void)loadRewardedAd{*request=[request];[GADRewardedAdloadWithAdUnitID:@"ca-app-pub-3940256099942544/4806952744"request:requestcompletionHandler:^(GADRewardedAd*ad,NSError*error){if(error){NSLog(@"Rewarded ad failed to load with error: %@",[errorlocalizedDescription]);return;}self.rewardedAd=ad;self.rewardedAd.fullScreenContentDelegate=self;/// Set the ad to be the delegate of its ad metadata.self.rewardedAd.adMetadataDelegate=self;NSLog(@"Rewarded ad loaded.");}];}/#pragmamarkGADAdMetadataDelegateimplementation-(void)adMetadataDidChange:(id<GADAdMetadataProvider>)ad{NSDictionary<NSString*,id>*adMetadata=_rewardedAd.adMetadata;NSString*adId=adMetadata[@"AdId"];}
메타데이터를 가져온 후 관심 있는 키의 번들을 확인할 수 있습니다. 광고 유형에 따라 연결된 광고 메타데이터 키가 다를 수 있습니다. VAST 동영상 광고에는 다음 키가 있습니다.
키
유형
설명
AdId
문자열
광고의 ID입니다. 사용할 수 없는 경우 빈 문자열입니다.
AdTitle
문자열
제목입니다. 지정하지 않은 경우 비어 있습니다.
CreativeDurationMs
정수
선택한 광고 소재의 길이(밀리초)입니다(비선형인 경우 -1).
TraffickingParameters
문자열
트래피킹 매개변수입니다. 사용할 수 없는 경우 빈 문자열입니다.
DealId
문자열
현재 광고의 래퍼 체인에 있는 첫 번째 거래 ID(위에서 시작) 또는 이 정보를 사용할 수 없는 경우 빈 문자열입니다.
AdSystem
문자열
광고의 소스 광고 서버입니다. 사용할 수 없는 경우 비어 있습니다.
CreativeId
문자열
광고에 대해 선택된 광고 소재의 ID입니다. 사용할 수 없는 경우 비어 있습니다.
MediaURL
문자열
선택한 미디어의 URL입니다.
Wrappers
배열
배열은 가장 안쪽 래퍼 광고(인라인 광고에 가까움)에서 시작하여 가장 바깥쪽 래퍼 광고로 이동하는 요소로 채워집니다. 배열의 각 요소는 다음 키와 값을 포함하는 사전입니다.
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eThis guide helps publishers integrate ad metadata with the Google Mobile Ads iOS SDK for rewarded and rewarded interstitial ad formats.\u003c/p\u003e\n"],["\u003cp\u003eYou need to set the ad as its own \u003ccode\u003eGADAdMetadataDelegate\u003c/code\u003e and implement the \u003ccode\u003eadMetadataDidChange:\u003c/code\u003e method to receive ad metadata updates.\u003c/p\u003e\n"],["\u003cp\u003eAd metadata may not be available immediately when an ad loads, so waiting for the \u003ccode\u003eadMetadataDidChange:\u003c/code\u003e callback is recommended.\u003c/p\u003e\n"],["\u003cp\u003eVAST video ads provide specific metadata keys like AdId, AdTitle, CreativeDurationMs, and more, which can be accessed through the ad's \u003ccode\u003eadMetadata\u003c/code\u003e property.\u003c/p\u003e\n"]]],[],null,["# Ad Metadata\n\nSelect platform: [Android](/ad-manager/mobile-ads-sdk/android/ad-metadata \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/ad-metadata \"View this page for the iOS platform docs.\")\n\n\u003cbr /\u003e\n\nThis guide is intended for publishers integrating ad metadata with the Google\nMobile Ads iOS SDK.\n\nPrerequisites\n-------------\n\n- Google Mobile Ads SDK minimum version 7.41.0.\n- Complete the steps in either of the guides below:\n - [Rewarded ads](/ad-manager/mobile-ads-sdk/ios/rewarded)\n - [Rewarded interstitial\n ads](/ad-manager/mobile-ads-sdk/ios/rewarded-interstitial)\n\nFetching ad metadata\n--------------------\n\nTo have an app know more about ads that are served, set the ad to be its own\n`GADAdMetadataDelegate`. Then you can listen for ad metadata changes by\nimplementing the `adMetadataDidChange:` method on `GADAdMetadataDelegate`. Once\nthis delegate is called, check the `adMetadata` property on the ad.\n\n`adMetadataDidChange:` is called just after an ad loads or when an ad's\nmetadata changes asynchronously after it loads. It is not guaranteed that ad\nmetadata is available at load time, so we recommend waiting for this callback\nbefore accessing an ad's metadata.\n\nHere is a code example showing how to retrieve the ad metadata for a rewarded\nad: \n\n @interface ViewController () \u003cGADFullScreenContentDelegate, GADAdMetadataDelegate\u003e\n\n @end\n\n @implementation ViewController\n - (void)loadRewardedAd {\n *request = [ request];\n [GADRewardedAd\n loadWithAdUnitID:@\"ca-app-pub-3940256099942544/4806952744\"\n request:request\n completionHandler:^(GADRewardedAd *ad, NSError *error) {\n if (error) {\n NSLog(@\"Rewarded ad failed to load with error: %@\", [error localizedDescription]);\n return;\n }\n self.rewardedAd = ad;\n self.rewardedAd.fullScreenContentDelegate = self;\n\n /// Set the ad to be the delegate of its ad metadata.\n self.rewardedAd.adMetadataDelegate = self;\n\n NSLog(@\"Rewarded ad loaded.\");\n }];\n }\n\n /#pragma mark GADAdMetadataDelegate implementation\n - (void)adMetadataDidChange:(id\\\u003cGADAdMetadataProvider\\\u003e)ad {\n NSDictionary\\\u003cNSString\\*, id\\\u003e \\*adMetadata = _rewardedAd.adMetadata;\n NSString \\*adId = adMetadata\\[@\"AdId\"\\];\n }\n\nAfter retrieving the metadata, you can check the Bundle for the keys you care\nabout. Different types of ads might have different ad metadata keys associated\nwith them. VAST video ads have the following keys:\n\n| Key | Type | Description |\n|-------------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `AdId` | String | The ID of the ad, or the empty string if not available. |\n| `AdTitle` | String | The title, empty if not specified. |\n| `CreativeDurationMs` | Integer | The selected creative duration in milliseconds, `-1` if non-linear. |\n| `TraffickingParameters` | String | Trafficking parameters, or the empty string if not available. |\n| `DealId` | String | The first deal ID present in the wrapper chain for the current ad, starting from the top, or the empty string if this information is not available. |\n| `AdSystem` | String | The source ad server of the ad, empty if not available. |\n| `CreativeId` | String | The ID of the selected creative for the ad, empty if not available. |\n| `MediaURL` | String | The URL of the selected media. |\n| `Wrappers` | Array | The array is populated with elements beginning at the innermost wrapper ad (close to the inline ad) moving outwards to the outermost wrapper ad. Each element in the array is a dictionary that contains the following keys and values. `AdId` : *String*. Ad ID used for wrapper ad, empty if not available. `AdSystem` : *String*. Ad system used for wrapper ad, empty if not available. `CreativeId` : *String*. Creative ID used for wrapper ad, empty if not available. |\n\n| **Note:** Only VAST wrapper ads have `Wrappers` key in the ad metadata. VAST inline ads don't contain `Wrappers` metadata."]]