컴패니언 광고 지원 추가
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 가이드는 iOS IMA 구현에 컴패니언 광고를 추가하는 데 관심이 있는 게시자를 대상으로 합니다.
기본 요건
- IMA SDK가 통합된 iOS 애플리케이션
- 컴패니언 광고를 반환하도록 구성된 광고 태그
유용한 사전 참고 자료
앱에 IMA SDK를 아직 구현하지 않은 경우 시작 가이드를 확인하세요.
앱에 동반 광고 추가
컴패니언의 UIView 만들기
컴패니언을 요청하기 전에 레이아웃에 컴패니언을 위한 공간을 만들어야 합니다. 스토리보드에서 뷰를 ViewController
로 드래그 앤 드롭하고 컴패니언 광고에 맞게 크기를 조정합니다. 그런 다음 컴패니언 슬롯이 구현의 변수에 연결되어 있는지 확인합니다 (이 예에서는 companionView라는 변수를 사용함). 아래 스크린샷에서 밝은 회색 뷰는 컴패니언 광고 뷰입니다.
IMACompanionAdSlot 만들기
다음 단계는 뷰에서 IMACompanionAdSlot 객체를 빌드하는 것입니다. IMA SDK는 뷰의 높이와 너비에 일치하는 크기를 가진 VAST 응답의 컴패니언으로 컴패니언 광고 슬롯을 채웁니다. IMA SDK는 유동 크기 컴패니언 사용도 지원합니다.
ViewController.h
@property(nonatomic, weak) IBOutlet UIView *companionView;
ViewController.m
self.companionSlot =
[[IMACompanionAdSlot alloc] initWithView:self.companionView
width:self.companionView.frame.size.width
height:self.companionView.frame.size.height];
컴패니언 광고 슬롯을 광고 컨테이너에 전달
마지막으로 컴패니언 슬롯 배열을 IMAAdDisplayContainer
생성자에 전달하여 이 컴패니언 슬롯이 존재함을 SDK에 알려야 합니다.
ViewController.m
return [[IMAAdDisplayContainer alloc] initWithAdContainer:self.videoView
viewController:self
companionSlots:@[ self.companionSlot ]];
다음은 이제 애플리케이션에 컴패니언 광고가 표시됩니다.
유동형 컴패니언 광고 표시
이제 IMA에서 유동 컴패니언 광고를 지원합니다. 이러한 동반 광고는 광고 슬롯의 크기에 맞게 크기를 조절할 수 있습니다. 상위 뷰의 너비를 100% 채운 다음, 동반자의 콘텐츠에 맞게 높이를 조정합니다. Ad Manager에서 Fluid
컴패니언 크기를 사용하여 설정됩니다.
이 값을 설정할 위치는 다음 이미지를 참고하세요.
유연한 호환 기기를 위해 iOS 앱 업데이트
width
및 height
를 제외하고 view
매개변수만 사용하여 IMACompanionAdSlot
를 시작하여 유동형 컴패니언 슬롯을 선언할 수 있습니다.
ViewController.m
self.companionSlot =
[[IMACompanionAdSlot alloc] initWithView:self.companionView];
FAQ
- 가이드를 따랐는데 컴패니언 광고가 표시되지 않습니다. 어떻게 해야 하나요?
- 먼저 태그가 실제로 동반자를 반환하는지 확인합니다. 이렇게 하려면 웹브라우저에서 태그를 열고 CompanionAds 태그를 찾습니다. 이 경우 반환되는 컴패니언의 크기가 컴패니언을 표시하려는 UIView의 크기와 동일한지 확인하세요.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-31(UTC)
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eThis guide helps iOS publishers integrate companion ads using the IMA SDK.\u003c/p\u003e\n"],["\u003cp\u003eYou need an iOS app with the IMA SDK and an ad tag returning companion ads to get started.\u003c/p\u003e\n"],["\u003cp\u003eCreate a UIView for the companion ad and an IMACompanionAdSlot tied to it.\u003c/p\u003e\n"],["\u003cp\u003eInform the SDK about the companion slot by passing it to the IMAAdDisplayContainer.\u003c/p\u003e\n"],["\u003cp\u003eFluid companion ads can be implemented for automatic resizing to fit content.\u003c/p\u003e\n"]]],[],null,["Select platform: [HTML5](/interactive-media-ads/docs/sdks/html5/client-side/companions \"View this page for the HTML5 platform docs.\") [Android](/interactive-media-ads/docs/sdks/android/client-side/companions \"View this page for the Android platform docs.\") [iOS](/interactive-media-ads/docs/sdks/ios/client-side/companions \"View this page for the iOS platform docs.\")\n\nThis guide is intended for publishers interested in adding companion ads to their iOS IMA implementation.\n\nPrerequisites\n\n- iOS Application with the IMA SDK integrated.\n- An ad tag configured to return a companion ad.\n - If you need a sample, check out our [FAQ](/interactive-media-ads/docs/sdks/ios/client-side/faq#4).\n\nHelpful primers\n\nIf you still need to implement the IMA SDK in your app, check out our [Get Started guide](/interactive-media-ads/docs/sdks/ios/client-side).\n\nAdd companion ads to your app\n\nCreate a UIView for your companion\n\nBefore requesting a companion, you need to create a space for it in your layout. In your storyboard, drag and drop a View onto your `ViewController` and size it to your companion ad. Then, make sure your companion slot is tied to a variable in your implementation (this example uses a variable called companionView). In the screenshot below, the light gray view is the companion ad view:\n\nCreate an IMACompanionAdSlot\n\nThe next step is to build an IMACompanionAdSlot object from your view. The IMA SDK\npopulates the companion ad slot with any companions from the VAST response that have dimensions\nmatching the view's height and width. The IMA SDK also supports using\n[fluid sized companions](/interactive-media-ads/docs/sdks/ios/client-side/companions#display-fluid-companion-ads).\n**ViewController.h** \n\n```transact-sql\n@property(nonatomic, weak) IBOutlet UIView *companionView;\n```\n**ViewController.m** \n\n```objective-c\nself.companionSlot =\n [[IMACompanionAdSlot alloc] initWithView:self.companionView\n width:self.companionView.frame.size.width\n height:self.companionView.frame.size.height];\n```\n\nPass the companion ad slot to your ad container\n\nLastly, you need to let the SDK know that this companion slot exists by passing an array of your companion slots to the `IMAAdDisplayContainer` constructor:\n**ViewController.m** \n\n```objective-c\nreturn [[IMAAdDisplayContainer alloc] initWithAdContainer:self.videoView\n viewController:self\n companionSlots:@[ self.companionSlot ]];\n```\n\nThat's all there is to it! Your application is now displaying companion ads.\n\nDisplay fluid companion ads\n\nIMA now supports fluid companion ads. These companions ads can resize to match the size of\nthe ad slot. They fill 100% of the width of parent view, then resize their height to fit the\ncompanion's content. They're set by using the `Fluid` companion size in Ad Manager.\nSee the following image for where to set this value.\n\nUpdate iOS apps for fluid companions\n\nYou can declare a fluid companion slot by initiating the\n[`IMACompanionAdSlot`](/interactive-media-ads/docs/sdks/ios/client-side/reference/Classes/IMACompanionAdSlot#-initwithview:)\nwith only the `view` parameter; excluding `width` and\n`height`.\n**ViewController.m** \n\n```objective-c\nself.companionSlot =\n [[IMACompanionAdSlot alloc] initWithView:self.companionView];\n```\n\nFAQ\n\nI followed the guide, but I'm not seeing companion ads. What should I do?\n: First, check to make sure your tag really is returning companions. To do this, open the tag in a web browser and look for a CompanionAds tag. If you see that, check to make sure the size of the companion being returned is the same size as the UIView in which you're trying to display it."]]