کلاس GADMobileAds تنظیمات کلی را برای کنترل برخی اطلاعات جمع آوری شده توسط Google Mobile Ads SDK فراهم می کند.
کنترل حجم تبلیغات ویدیویی
اگر برنامه شما دارای کنترلهای میزان صدا است، مانند موسیقی سفارشی یا حجم جلوههای صوتی، افشای حجم برنامه در Google Mobile Ads SDK به تبلیغات ویدیویی امکان میدهد به تنظیمات حجم برنامه احترام بگذارند. این تضمین می کند که کاربران تبلیغات ویدیویی را با حجم صوتی مورد انتظار دریافت کنند.
میزان صدای دستگاه که از طریق دکمه های صدا یا نوار لغزنده سطح سیستم عامل کنترل می شود، میزان صدا را برای خروجی صدای دستگاه تعیین می کند. با این حال، برنامهها میتوانند بهطور مستقل سطح صدا را نسبت به میزان صدای دستگاه تنظیم کنند تا تجربه صوتی را متناسب کنند.
برای فرمتهای تبلیغات میانبینی باز، بنر، بینابینی، پاداش و پاداش، میتوانید با تنظیم ویژگی applicationVolume ، حجم نسبی برنامه را به Google Mobile Ads SDK گزارش کنید. مقادیر حجم آگهی معتبر از 0.0 (بی صدا) تا 1.0 (حجم فعلی دستگاه) متغیر است. در اینجا مثالی از نحوه گزارش حجم نسبی برنامه به SDK آورده شده است:
سویفت
funcviewDidLoad(){super.viewDidLoad()// Set app volume to be half of the current device volume.MobileAds.shared.applicationVolume=0.5...}
هدف-C
-(void)viewDidLoad{[superviewDidLoad];// Set app volume to be half of the current device volume.GADMobileAds.sharedInstance.applicationVolume=0.5;...}
برای قالبهای تبلیغاتی باز، بنر، بینابینی، با پاداش و پاداش، میتوانید با تنظیم ویژگی applicationMuted به Google Mobile Ads SDK اطلاع دهید که حجم برنامه بیصدا شده است:
سویفت
MobileAds.shared.applicationMuted=true
هدف-C
GADMobileAds.sharedInstance.applicationMuted=YES;
به طور پیشفرض، applicationVolume روی 1 (حجم فعلی دستگاه) و applicationMuted روی NO تنظیم شده است.
تبلیغات بومی
برای دستورالعملهای مربوط به کنترل تنظیمات بیصدا به GADVideoOptions مراجعه کنید. برای تبلیغات بومی، پشتیبانی از کنترل حجم صدای سفارشی وجود ندارد.
جلسات صوتی
جلسات صوتی به شما این امکان را می دهد که اهداف خود را برای رفتار صوتی برنامه خود به سیستم بیان کنید. اطلاعات بیشتر در مورد جلسات صوتی را می توانید در راهنمای برنامه نویسی جلسه صوتی اپل بیابید. گزینه های موجود برای مدیریت صدای Google Mobile Ads SDK از طریق ویژگی audioVideoManager است.
اگر از صدا در برنامه خود استفاده نمی کنید، نیازی به استفاده از این API ها ندارید. Google Mobile Ads SDK به طور خودکار دسته جلسه صوتی را هنگام پخش صدا مدیریت می کند. اگر صدا را در برنامه خود پخش می کنید و می خواهید کنترل دقیق تری بر نحوه و زمان پخش صدا در Google Mobile Ads SDK داشته باشید، می توانید از این API ها استفاده کنید.
اگر میخواهید مسئولیت مدیریت دستهبندی جلسه صوتی را خودتان به عهده بگیرید، در مدیر ویدیوی صوتی، میتوانید ویژگی audioSessionIsApplicationManaged را روی YES تنظیم کنید.
اگر میخواهید دسته جلسه صوتی را مدیریت کنید، میتوانید GADAudioVideoManagerDelegate پیادهسازی کنید و ویژگی delegate را در مدیر ویدیوی صوتی تنظیم کنید تا از رویدادهای پخش ویدیو و صدا تبلیغات مطلع شود. سپس باید طبق راهنمای برنامه نویسی جلسه صوتی اپل، دسته بندی جلسه صوتی را به دسته مربوطه تغییر دهید.
در اینجا یک نمونه کد ساده آمده است که اگر برنامه شما با استفاده از APIهای بالا موسیقی پخش می کند، رویکرد توصیه شده را نشان می دهد:
سویفت
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()}
هدف-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];}
گزارش خرابی
Google Mobile Ads SDK استثناهایی را که در یک برنامه iOS رخ میدهند بررسی میکند و در صورتی که توسط SDK ایجاد شده باشد، آنها را ثبت میکند. این استثناها سپس در نسخههای SDK آینده بررسی میشوند.
گزارش خرابی به طور پیش فرض فعال است. اگر نمیخواهید استثناهای مربوط به SDK ثبت شوند، میتوانید با فراخوانی روش disableSDKCrashReporting ، این ویژگی را غیرفعال کنید. بهترین زمان برای فراخوانی این روش زمانی است که برنامه راه اندازی می شود:
اگر برنامه شما الزامات خاصی دارد، می توانید NSUserDefaults اختیاری gad_has_consent_for_cookies تنظیم کنید. اگر تنظیمات برگزیده gad_has_consent_for_cookies روی صفر تنظیم شده باشد، SDK تبلیغات موبایل Google، تبلیغات محدود (LTD) را فعال میکند.
تاریخ آخرین بهروزرسانی 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\");"]]