يمكن أن تعمل حزمة تطوير البرامج (SDK) في وضع واحد أو أكثر، وذلك حسب استجابة الإعلان التي تتلقّاها من خادم الإعلانات.
إعلان واحد
إعلان يمكن تشغيله في أي وقت عند إرسال الرسالة start
إلى IMAAdsManager لا يلزم إجراء أي عملية تهيئة خاصة لتشغيل إعلان واحد.
مجموعة إعلانات متسلسلة
إعلانات متعدّدة يتم تشغيلها بالتسلسل عند إرسال الرسالة start إلى IMAAdsManager. لا يلزم إجراء أي عملية تهيئة خاصة لتشغيل حزمة إعلانية واحدة.
قواعد الإعلانات
قائمة تشغيل لفواصل إعلانية مجدولة في أوقات معيّنة مقابل محتوى محدّد يتم تجاهل الرسالة start في وضع "قواعد الإعلانات". يمكن جدولة عدّة فواصل إعلانية ضمن قائمة تشغيل واحدة (مثل الإعلانات ما قبل التشغيل والإعلانات أثناء التشغيل والإعلانات ما بعد التشغيل). لمزيد من التفاصيل حول التنفيذ، يُرجى الاطّلاع على قسم قواعد الإعلانات أدناه.
قواعد الإعلانات
تتيح حزمة تطوير البرامج (SDK) لإعلانات الوسائط التفاعلية على نظام التشغيل iOS إنشاء قوائم تشغيل إعلانية آلية بالكامل. تُدرج هذه الميزة فواصل إعلانية في المحتوى على النحو المحدّد في إدارة إعلانات Google عند عرض إعلاناتك. ويبسّط أيضًا بشكل كبير رمز مشغّل الفيديو اللازم لعرض فواصل إعلانية، بما في ذلك الإعلانات قبل التشغيل وأثناء التشغيل وبعد التشغيل.
عند عرض الإعلانات في "مدير إعلانات Google"، يمكن تحديد قواعد إعلانية مختلفة، مثل "عرض فاصل إعلاني دائمًا في بداية المحتوى" أو "عرض فاصل إعلاني مدته دقيقة واحدة كل 30 دقيقة من المحتوى".
عند طلب الإعلانات، يمكن لخادم الإعلانات عرض قائمة تشغيل إعلانات. تعالج حزمة SDK قائمة التشغيل وتجدول تلقائيًا الفواصل الإعلانية التي تم تحديدها.
عند تهيئة AdsManager، يتم تمرير العنصر IMAContentPlayhead
من خلال استدعاء initializeWithContentPlayhead:adsRenderingSettings:. إذا كنت تستخدم AVPlayer لعرض المحتوى، عليك تمرير مثيل من IMAAVPlayerContentPlayhead إلى حزمة SDK عند إنشاء adDisplayContainer. يُستخدَم هذا العنصر لتتبُّع مستوى تقدّم تشغيل المحتوى، وبالتالي يتم إدراج الفواصل الإعلانية تلقائيًا في الأوقات المحدّدة في "إدارة إعلانات Google".
نفِّذ currentTime لعرض الوقت الحالي لمشغّل الفيديو.
غيِّر طلب تهيئة IMAAdsManager إلى استخدام initializeWithContentPlayhead:self.
يتم استخدام IMAAdsManagerDelegate
لإيقاف المحتوى مؤقتًا واستئنافه أثناء عرض فواصل إعلانية.
ملاحظة: عند انتهاء تشغيل المحتوى أو توقّف المستخدم عن تشغيله، احرص على استدعاء contentComplete
في IMAAdsLoader لإعلام حزمة تطوير البرامج (SDK) بأنّه تم الانتهاء من تشغيل المحتوى. بعد ذلك، تعرض حزمة تطوير البرامج (SDK) فاصل الإعلانات ما بعد التشغيل، إذا تم تحديد موعد له.
يتم إطلاق الحدث ALL_ADS_COMPLETED عند تشغيل جميع الفواصل الإعلانية. بالإضافة إلى ذلك، يُرجى العِلم أنّ تتبُّع المحتوى يبدأ عند استدعاء طريقة initializeWithContentPlayhead:adsRenderingSettings الخاصة بـ IMAAdsManager، ويجب دائمًا استدعاء initializeWithContentPlayhead:adsRenderingSettings قبل تشغيل المحتوى.
تاريخ التعديل الأخير: 2025-09-06 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-09-06 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eThe Google IMA iOS SDK allows you to integrate ads into your video content using a WebView for ad requests, parsing, tracking, and rendering.\u003c/p\u003e\n"],["\u003cp\u003eIt supports three main operation modes: single ad, ad pod (multiple ads played back-to-back), and ad rules for scheduled ad breaks.\u003c/p\u003e\n"],["\u003cp\u003eAd rules simplify ad integration by automating ad playlist management based on Google Ad Manager settings, requiring an \u003ccode\u003eIMAContentPlayhead\u003c/code\u003e for content tracking.\u003c/p\u003e\n"],["\u003cp\u003eThe SDK utilizes the \u003ccode\u003eIMAAdsManagerDelegate\u003c/code\u003e to control content playback during ad breaks and requires signaling content completion via \u003ccode\u003econtentComplete\u003c/code\u003e for post-roll ads.\u003c/p\u003e\n"]]],[],null,["Select platform: [HTML5](/interactive-media-ads/docs/sdks/html5/client-side/ad-rules \"View this page for the HTML5 platform docs.\") [Android](/interactive-media-ads/docs/sdks/android/client-side/ad-rules \"View this page for the Android platform docs.\") [iOS](/interactive-media-ads/docs/sdks/ios/client-side/ad-rules \"View this page for the iOS platform docs.\") [tvOS](/interactive-media-ads/docs/sdks/tvos/client-side/ad-rules \"View this page for the tvOS platform docs.\")\n| **Note:** The iOS SDK uses a WebView to load a JavaScript back end. This WebView is used to make ad requests, parse responses, ping tracking URLs, and render the ad UI.\n\nSDK operation modes\n\nThe SDK can operate in one or more modes, depending on the ad response it receives from the ad\nserver.\n\nSingle ad\n: An ad that can be played at any time when the `start`\n message is sent to the `IMAAdsManager`. No special initialization\n is necessary to play a single ad.\n:\n\nAd pod\n: Several ads that play back to back when the `start` message is sent to\n the `IMAAdsManager`. No special initialization is necessary to\n play a single ad pod.\n\nAd rules\n: A playlist of ad breaks scheduled at certain times against particular\n content. The `start` message is ignored in ad rules mode. There can\n be several ad breaks scheduled within a single playlist (e.g., pre-roll,\n mid-roll, post-roll). For further implementation details, see the\n [Ad Rules](#ad-rules) section below.\n\nAd rules\n\nIMA iOS\nSDK supports fully automated ad playlists. This feature\ninserts ad breaks into the content as specified in\n[Google Ad Manager](//admanager.google.com/)\nwhen trafficking your ads. It also greatly simplifies the video player code\nnecessary to support ad breaks, including pre-rolls, mid-rolls, and post-rolls.\n\n- When trafficking ads in Ad Manager, it is possible to specify various ad rules like \"always play ad break at the beginning of the content\" or \"play a one-minute ad break every 30 minutes of content\".\n- When ads are requested, the ad server can return an ad playlist. The SDK processes the playlist and automatically schedules the ad breaks that have been specified.\n- When initializing the `AdsManager`, an `IMAContentPlayhead` object is passed in via the `initializeWithContentPlayhead:adsRenderingSettings:` call. If you are using an AVPlayer to display your content, you pass an instance of `IMAAVPlayerContentPlayhead` to the SDK when you create your `adDisplayContainer`. This object is used to track the progress of the content playback so ad breaks are automatically inserted at the times specified in Ad Manager. \n\n **With AVPlayer:** \n\n ```objective-c\n IMAContentPlayhead *contentPlayhead =\n [[IMAAVPlayerContentPlayhead alloc] initWithAVPlayer:self.contentAVPlayer];\n IMAAdsRequest *request = [[IMAAdsRequest alloc] initWithAdTagUrl:adTagUrl\n adDisplayContainer:adDisplayContainer\n contentPlayhead:contentPlayhead\n userContext:nil];\n ```\n\n **Without AVPlayer:**\n 1. Implement the `IMAContentPlayhead` interface.\n 2. Implement `currentTime` to return the current time of your video player.\n 3. Change the `IMAAdsManager` initialization call to use `initializeWithContentPlayhead:self`.\n- The [IMAAdsManagerDelegate](/interactive-media-ads/docs/sdks/ios/client-side/reference/Protocols/IMAAdsManagerDelegate) is used to pause and resume the content as ad breaks are played.\n\n**Note:** When the content has finished playing or\nthe user has stopped playback, be sure to call `contentComplete`\non the `IMAAdsLoader` in order to signal to the SDK that the content\nhas finished playing. The SDK then plays the post-roll ad break, if one has been scheduled.\nThe `ALL_ADS_COMPLETED` event is raised when all ad breaks have\nbeen played. In addition, note that content tracking begins when\n`IMAAdsManager`'s `initializeWithContentPlayhead:adsRenderingSettings`\nmethod is called and you should always call `initializeWithContentPlayhead:adsRenderingSettings`\nbefore playing content."]]