يوفّر صف GADMobileAds إعدادات عامة للتحكّم في بعض المعلومات التي تجمعها حزمة "SDK لإعلانات Google على الأجهزة الجوّالة".
التحكّم في مستوى صوت إعلان الفيديو
إذا كان تطبيقك يتضمّن عناصر تحكّم في مستوى الصوت، مثل مستويات مخصّصة للموسيقى أو المؤثرات الصوتية، فإنّ الإفصاح عن مستوى الصوت في التطبيق لحزمة "SDK لإعلانات Google على الأجهزة الجوّالة" يتيح لإعلانات الفيديو مراعاة إعدادات مستوى الصوت في التطبيق. يضمن ذلك عرض إعلانات الفيديو للمستخدمين بمستوى الصوت المتوقّع.
يحدّد مستوى صوت الجهاز، الذي يتم التحكّم فيه من خلال أزرار مستوى الصوت أو شريط تمرير مستوى الصوت على مستوى نظام التشغيل، مستوى صوت إخراج الصوت من الجهاز. ومع ذلك، يمكن للتطبيقات ضبط مستويات الصوت بشكل مستقل بما يتناسب مع مستوى صوت الجهاز لتخصيص تجربة الصوت.
بالنسبة إلى أشكال الإعلانات على شاشة فتح التطبيق وإعلانات البانر والإعلانات البينية والإعلانات بمكافأة والإعلانات البينية بمكافأة، يمكنك إبلاغ حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" بمستوى صوت التطبيق النسبي من خلال ضبط السمة applicationVolume. تتراوح قيم مستوى صوت الإعلان الصالحة بين
0.0 (صامت) و1.0 (مستوى صوت الجهاز الحالي). في ما يلي مثال على كيفية إرسال عدد التطبيقات النسبي إلى حزمة تطوير البرامج (SDK):
Swift
funcviewDidLoad(){super.viewDidLoad()// Set app volume to be half of the current device volume.MobileAds.shared.applicationVolume=0.5...}
Objective-C
-(void)viewDidLoad{[superviewDidLoad];// Set app volume to be half of the current device volume.GADMobileAds.sharedInstance.applicationVolume=0.5;...}
بالنسبة إلى أشكال الإعلانات "إعلان أثناء تشغيل التطبيق" و"بانر" و"بيني" و"بمكافأة" و"بيني مع مكافأة"، يمكنك إعلام حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" بأنّه تم كتم صوت التطبيق من خلال ضبط السمة applicationMuted:
Swift
MobileAds.shared.applicationMuted=true
Objective-C
GADMobileAds.sharedInstance.applicationMuted=YES;
يتم ضبط applicationVolume تلقائيًا على 1 (مستوى صوت الجهاز الحالي)
ويتم ضبط applicationMuted على NO.
إعلانات مدمجة مع المحتوى
اطّلِع على
GADVideoOptions
للحصول على تعليمات حول التحكّم في إعدادات كتم الصوت. بالنسبة إلى "الإعلانات المدمجة مع المحتوى"، لا تتوفّر ميزة التحكّم المخصّص في مستوى الصوت.
جلسات الصوت
تتيح لك جلسات الصوت التعبير للنظام عن نواياك بشأن سلوك الصوت في تطبيقك. يمكنك الاطّلاع على معلومات إضافية حول جلسات الصوت في دليل برمجة جلسات الصوت من Apple.
تتوفّر خيارات إدارة الصوت في حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" من خلال السمة audioVideoManager.
إذا كنت لا تستخدم الصوت في تطبيقك، لن تحتاج إلى استخدام واجهات برمجة التطبيقات هذه.
تتولّى حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" تلقائيًا إدارة فئة جلسة الصوت عند تشغيل الصوت. إذا كنت تشغّل الصوت في تطبيقك وأردت التحكّم بشكل أكبر في طريقة تشغيل حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" للصوت وتوقيت تشغيله، يمكنك الاستفادة من واجهات برمجة التطبيقات هذه.
في "مدير الفيديو والصوت"، يمكنك ضبط السمة
audioSessionIsApplicationManaged
على YES إذا كنت تريد تحمّل مسؤولية إدارة فئة جلسة الصوت بنفسك.
إذا أردت إدارة فئة جلسة الصوت، يمكنك تنفيذ
GADAudioVideoManagerDelegate
وضبط السمة delegate
في "مدير الفيديو والصوت" لتلقّي إشعارات بشأن أحداث تشغيل الفيديو والصوت للإعلانات. عليك بعد ذلك تغيير فئة جلسة الصوت إلى الفئة ذات الصلة وفقًا لدليل برمجة جلسة الصوت من Apple.
في ما يلي نموذج رمز مبسط يعرض الطريقة المقترَحة إذا كان تطبيقك يشغّل الموسيقى، وذلك باستخدام واجهات برمجة التطبيقات المذكورة أعلاه:
Swift
funcsetUp(){MobileAds.shared.audioVideoManager.delegate=selfMobileAds.shared.audioVideoManager.audioSessionIsApplicationManaged=false}// MARK: - GADAudioVideoManagerDelegatefuncaudioVideoManagerWillPlayAudio(_audioVideoManager:GADAudioVideoManager){// The Google Mobile Ads SDK is notifying your app that it will play audio. You// could optionally pause music depending on your apps design.MyAppObject.shared.pauseAllMusic()}funcaudioVideoManagerDidStopPlayingAudio(_audioVideoManager:GADAudioVideoManager){// The Google Mobile Ads SDK is notifying your app that it has stopped playing// audio. Depending on your design, you could resume music here.MyAppObject.shared.resumeAllMusic()}
Objective-C
-(void)setUp{GADMobileAds.sharedInstance.audioVideoManager.delegate=self;GADMobileAds.sharedInstance.audioVideoManager.audioSessionIsApplicationManaged=NO;}#pragma mark - GADAudioVideoManagerDelegate-(void)audioVideoManagerWillPlayAudio:(GADAudioVideoManager*)audioVideoManager{// Google Mobile Ads SDK is notifying your app that it will play audio. You// could optionally pause music depending on your apps design.[MyAppObject.sharedInstancepauseAllMusic];}-(void)audioVideoManagerDidStopPlayingAudio:(GADAudioVideoManager*)audioVideoManager{// Google Mobile Ads SDK is notifying your app that it has stopped playing// audio. Depending on your design, you could resume music here.[MyAppObject.sharedInstanceresumeAllMusic];}
إعداد تقارير الأعطال
تفحص حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" الاستثناءات التي تحدث في تطبيق iOS وتسجّلها إذا كانت ناتجة عن حزمة SDK. ثم يتم معالجة هذه الاستثناءات في إصدارات حزمة SDK المستقبلية.
تكون ميزة الإبلاغ عن الأعطال مفعّلة تلقائيًا. إذا كنت لا تريد تسجيل الاستثناءات المتعلّقة بحزمة SDK، يمكنك إيقاف هذه الميزة من خلال استدعاء الطريقة disableSDKCrashReporting. أفضل وقت لاستدعاء هذه الطريقة هو عند تشغيل التطبيق:
إذا كان تطبيقك يتضمّن متطلبات خاصة، يمكنك ضبط
NSUserDefaultsgad_has_consent_for_cookies الاختياري. تتيح حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" عرض
إعلانات محدودة (LTD)
إذا تم ضبط قيمة الإعداد gad_has_consent_for_cookies على صفر.
تاريخ التعديل الأخير: 2025-09-02 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-02 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eThe \u003ccode\u003eGADMobileAds\u003c/code\u003e class allows you to manage global settings for the Mobile Ads SDK, including video ad volume and audio sessions.\u003c/p\u003e\n"],["\u003cp\u003eYou can control video ad volume and mute state for App Open, Banner, Interstitial, Rewarded, and Rewarded Interstitial ad formats, but these settings do not apply to native ads or mediated networks.\u003c/p\u003e\n"],["\u003cp\u003eFor apps that manage their own audio, you can use the \u003ccode\u003eaudioVideoManager\u003c/code\u003e and its delegate to coordinate audio playback between your app and the SDK.\u003c/p\u003e\n"],["\u003cp\u003eBy default, the SDK automatically handles audio sessions and crash reporting, but you can disable or customize these behaviors if needed.\u003c/p\u003e\n"],["\u003cp\u003eYou can enable limited ads by setting the \u003ccode\u003egad_has_consent_for_cookies\u003c/code\u003e preference in \u003ccode\u003eNSUserDefaults\u003c/code\u003e to zero if your app has specific consent requirements.\u003c/p\u003e\n"]]],["The `GADMobileAds` class allows control over audio and crash reporting. Apps with custom volume controls can set `applicationVolume` (0.0-1.0) or `applicationMuted` to manage video ad volume relative to device volume. The `audioVideoManager` provides control over audio session categories, using `audioSessionIsApplicationManaged` and a delegate for audio playback events. The `disableSDKCrashReporting` method can disable crash reporting. Finally setting the `gad_has_consent_for_cookies` preference in `NSUserDefaults` can also be set.\n"],null,["Select platform: [Android](/admob/android/global-settings \"View this page for the Android platform docs.\") [iOS](/admob/ios/global-settings \"View this page for the iOS platform docs.\") [Unity](/admob/unity/global-settings \"View this page for the Unity platform docs.\")\n\n\u003cbr /\u003e\n\nThe `GADMobileAds` class provides global settings for controlling certain\ninformation collected by Google Mobile Ads SDK.\n\nVideo ad volume control **Note:** Video volume controls apply only to Google ads and are not forwarded to mediation networks.\n\nIf your app has its own volume controls, such as custom music or sound effect\nvolumes, disclosing app volume to Google Mobile Ads SDK enables video ads\nto respect app volume settings. This ensures users receive video ads with the\nexpected audio volume.\n\nThe device volume, controlled through volume buttons or OS-level volume slider,\ndetermines the volume for device audio output. However, apps can independently\nadjust volume levels relative to the device volume to tailor the audio\nexperience.\n\nFor App Open, Banner, Interstitial, Rewarded, and Rewarded Interstitial ad\nformats you can report the relative app volume to Google Mobile Ads SDK by\nsetting the `applicationVolume` property. Valid ad volume values range from\n`0.0` (silent) to `1.0` (current device volume). Here's an example of how to\nreport the relative app volume to the SDK: \n\nSwift \n\n func viewDidLoad() {\n super.viewDidLoad()\n // Set app volume to be half of the current device volume.\n MobileAds.shared.applicationVolume = 0.5\n ...\n }\n\nObjective-C \n\n - (void)viewDidLoad {\n [super viewDidLoad];\n // Set app volume to be half of the current device volume.\n GADMobileAds.sharedInstance.applicationVolume = 0.5;\n ...\n }\n\n| **Warning:** Lowering your app's audio volume reduces video ad eligibility and might reduce your app's ad revenue. You should only utilize this API if your app provides custom volume controls to the user, and the user's volume is properly reflected in the API.\n\nFor App Open, Banner, Interstitial, Rewarded, and Rewarded Interstitial ad\nformats, you can inform Google Mobile Ads SDK that the app volume has been\nmuted by setting the `applicationMuted` property: \n\nSwift \n\n MobileAds.shared.applicationMuted = true\n\nObjective-C \n\n GADMobileAds.sharedInstance.applicationMuted = YES;\n\nBy default, `applicationVolume` is set to `1` (the current device volume)\nand `applicationMuted` is set to `NO`.\n| **Warning:** Muting your app reduces video ad eligibility and might reduce your app's ad revenue. You should only utilize this API if your app provides a custom mute control to the user, and the user's mute decision is properly reflected in the API.\n\nNative ads\n\nSee\n[`GADVideoOptions`](/admob/ios/native/options#gadvideooptions)\nfor instructions on controlling the mute settings. For native ads, there isn't\nsupport for custom volume control.\n\nAudio sessions\n\nAudio sessions let you express to the system your intentions for your app's\naudio behavior. Additional information on audio sessions can be found in\nApple's [Audio Session Programming\nGuide](//developer.apple.com/library/content/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Introduction/Introduction.html).\nThe available options for managing Google Mobile Ads SDK audio is through\nthe\n[`audioVideoManager`](/admob/ios/api/reference/Classes/GADMobileAds#audioVideoManager)\nproperty.\n\nIf you don't use audio in your app, you don't need to use these APIs.\nGoogle Mobile Ads SDK automatically manages the audio session category when it\nplays audio. If you do play audio in your app and you want tighter control of\nhow and when Google Mobile Ads SDK plays audio, you can make use of these APIs.\n\nOn the audio video manager, you can set the\n[`audioSessionIsApplicationManaged`](/admob/ios/api/reference/Classes/GADAudioVideoManager#audioSessionIsApplicationManaged)\nproperty to `YES` if you want to take responsibility for managing the audio\nsession category yourself.\n\nIf you want to manage the audio session category, you can implement\n[`GADAudioVideoManagerDelegate`](/admob/ios/api/reference/Protocols/GADAudioVideoManagerDelegate)\nand set the [`delegate`](/admob/ios/api/reference/Classes/GADAudioVideoManager#/c:objc(cs)GADAudioVideoManager(py)delegate)\nproperty on the audio video manager to be notified of ads video and audio\nplayback events. You should then change the audio session category to the\nrelevant category according to [Apple's Audio Session Programming\nGuide](//developer.apple.com/library/content/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Introduction/Introduction.html).\n| **Key Point:** By default, the SDK sets the audio session category to `AVAudioSessionCategoryAmbient` when playing ads muted. If you prefer to have your app use [`AVAudioSessionCategoryOptionDuckOthers`](//developer.apple.com/documentation/avfoundation/avaudiosessioncategoryoptions/avaudiosessioncategoryoptionduckothers) in this scenario, you must implement the `GADAudioVideoManagerDelegate` protocol and set the audio video manager `audioSessionIsApplicationManaged` to `YES`.\n\nHere is a simplified code sample that shows the recommended approach if your\napp plays music, using the above APIs: \n\nSwift \n\n func setUp() {\n MobileAds.shared.audioVideoManager.delegate = self\n MobileAds.shared.audioVideoManager.audioSessionIsApplicationManaged = false\n }\n\n // MARK: - GADAudioVideoManagerDelegate\n func audioVideoManagerWillPlayAudio(_ audioVideoManager: GADAudioVideoManager) {\n // The Google Mobile Ads SDK is notifying your app that it will play audio. You\n // could optionally pause music depending on your apps design.\n MyAppObject.shared.pauseAllMusic()\n }\n\n func audioVideoManagerDidStopPlayingAudio(_ audioVideoManager: GADAudioVideoManager) {\n // The Google Mobile Ads SDK is notifying your app that it has stopped playing\n // audio. Depending on your design, you could resume music here.\n MyAppObject.shared.resumeAllMusic()\n }\n\nObjective-C \n\n - (void)setUp {\n GADMobileAds.sharedInstance.audioVideoManager.delegate = self;\n GADMobileAds.sharedInstance.audioVideoManager.audioSessionIsApplicationManaged = NO;\n }\n\n #pragma mark - GADAudioVideoManagerDelegate\n\n - (void)audioVideoManagerWillPlayAudio:(GADAudioVideoManager *)audioVideoManager {\n // Google Mobile Ads SDK is notifying your app that it will play audio. You\n // could optionally pause music depending on your apps design.\n [MyAppObject.sharedInstance pauseAllMusic];\n }\n\n - (void)audioVideoManagerDidStopPlayingAudio:(GADAudioVideoManager *)audioVideoManager {\n // Google Mobile Ads SDK is notifying your app that it has stopped playing\n // audio. Depending on your design, you could resume music here.\n [MyAppObject.sharedInstance resumeAllMusic];\n }\n\nCrash reporting\n\nGoogle Mobile Ads SDK inspects exceptions that occur in an iOS app and\nrecords them if they were caused by the SDK. These exceptions are then\naddressed in future SDK versions.\n\nCrash reporting is enabled by default. If you don't want SDK-related exceptions\nto be recorded, you can disable this feature by calling the\n`disableSDKCrashReporting` method. The best time to call this method is when\nthe app launches: \n\nSwift \n\n import GoogleMobileAds\n\n @UIApplicationMain\n class AppDelegate: UIResponder, UIApplicationDelegate {\n\n func application(_ application: UIApplication,\n didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -\u003e Bool {\n\n MobileAds.shared.disableSDKCrashReporting()\n return true\n }\n }\n\nObjective-C \n\n @import GoogleMobileAds;\n\n @implementation AppDelegate\n\n - (BOOL)application:(UIApplication *)application\n didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n\n \\[GADMobileAds disableSDKCrashReporting\\];\n return YES;\n }\n\n @end\n\nConsent for cookies settings\n\nIf your app has special requirements, you can set the optional\n[`NSUserDefaults`](//developer.apple.com/documentation/foundation/nsuserdefaults)\n`gad_has_consent_for_cookies`. Google Mobile Ads SDK enables\n\n[limited ads (LTD)](//support.google.com/admob/answer/10105530)\n\nif the `gad_has_consent_for_cookies` preference is set to zero. \n\nSwift \n\n UserDefaults.standard.set(0, forKey: \"gad_has_consent_for_cookies\")\n\nObjective-C \n\n NSUserDefaults.standardUserDefaults().setObject(Int(0),\n forKey: \"gad_has_consent_for_cookies\");"]]