هذا الدليل مخصّص للناشرين المهتمين بإضافة إعلانات مصاحبة إلى عملية تنفيذ IMA على نظام التشغيل iOS.
المتطلبات الأساسية
تطبيق iOS تم دمج حزمة تطوير البرامج لإعلانات الوسائط التفاعلية فيه
علامة إعلان تم ضبطها لعرض إعلان مصاحب
إذا كنت بحاجة إلى نموذج، يُرجى الاطّلاع على الأسئلة الشائعة.
مقدمات مفيدة
إذا كنت لا تزال بحاجة إلى تنفيذ حزمة تطوير البرامج لإعلانات الوسائط التفاعلية في تطبيقك، يمكنك الاطّلاع على دليل "البدء".
إضافة إعلانات مصاحبة إلى تطبيقك
إنشاء UIView للعنصر المصاحب
قبل طلب إعلان مصاحب، عليك إنشاء مساحة له في تصميم صفحتك. في لوحة السيناريو، اسحب "طريقة عرض" وأفلِتها في ViewController ثم غيِّر حجمها ليناسب الإعلان المصاحب. بعد ذلك، تأكَّد من ربط موضع الإعلان المصاحب بمتغيّر في عملية التنفيذ (يستخدم هذا المثال متغيّرًا باسم companionView). في لقطة الشاشة أدناه، يمثّل العرض الرمادي الفاتح عرض الإعلان المصاحب:
إنشاء IMACompanionAdSlot
الخطوة التالية هي إنشاء عنصر IMACompanionAdSlot من طريقة العرض. تعبئ أداة تطوير البرامج لإعلانات الوسائط التفاعلية فتحة الإعلان المرافق بأي إعلانات مرافقة من استجابة VAST تتضمّن أبعادًا تتطابق مع ارتفاع العرض وعرضه. تتيح حزمة IMA SDK أيضًا استخدام
إعلانات مصاحبة ذات حجم متغير.
أخيرًا، عليك إعلام حزمة SDK بأنّ هذه المساحة الإعلانية المصاحبة متوفّرة من خلال تمرير مصفوفة من المساحات الإعلانية المصاحبة إلى الدالة الإنشائية IMAAdDisplayContainer:
هذا كل ما في الأمر. يعرض تطبيقك الآن إعلانات مصاحبة.
عرض إعلانات مصاحبة مرنة
تتيح حزمة تطوير البرامج (SDK) الخاصة بـ IMA الآن الإعلانات المصاحبة المرنة. يمكن تغيير حجم هذه الإعلانات المصاحبة لتتطابق مع حجم الخانة الإعلانية. يتم ملء% 100 من عرض العرض الرئيسي، ثم يتم تغيير حجم الارتفاع ليناسب محتوى الإعلان المرافق. يتم ضبطها باستخدام حجم الإعلان المرافق Fluid في "مدير إعلانات Google".
راجِع الصورة التالية لمعرفة مكان ضبط هذه القيمة.
تحديث تطبيقات iOS لتوفير تجربة سلسة على الأجهزة المصاحبة
يمكنك تحديد خانة إعلان مصاحب مرن من خلال بدء
IMACompanionAdSlot
باستخدام المَعلمة view فقط، مع استبعاد width وheight.
اتّبعتُ الدليل، ولكن لا تظهر لي الإعلانات المصاحبة. ماذا يجب أن أفعل؟
أولاً، تأكَّد من أنّ علامتك تعرض إعلانات مصاحبة. لإجراء ذلك، افتح العلامة في متصفّح ويب وابحث عن علامة CompanionAds. إذا ظهرت لك هذه الرسالة، تأكَّد من أنّ حجم الإعلان المرافق الذي يتم عرضه هو الحجم نفسه الخاص بـ UIView الذي تحاول عرض الإعلان فيه.
تاريخ التعديل الأخير: 2025-09-06 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-09-06 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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."]]