启动广告检查器
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在测试广告植入之前,您必须先在应用中启动广告检查器。本页介绍了如何通过调试菜单启动广告检查器,以及如何以编程方式启动广告检查器。
前提条件
在继续之前,请执行以下操作:
- 完成初始前提条件中的所有项目,以创建 Ad Manager 账号、设置测试设备、初始化 Google 移动广告 SDK 并安装最新版本。
选择发布选项
您可以通过以下方式启动广告检查器:
- 通过应用内的调试菜单启动按钮,使用您在广告检查器设置中选择的手势。
- 通过
Google 移动广告 SDK
以编程方式实现。
如需通过调试菜单启动广告检查器,您无需对应用进行进一步更改。如需了解详情,请参阅检查移动应用广告投放情况。
请完成以下步骤:
- 找到在您的 Ad Manager 广告资源网中投放的广告。
- 轻触并按住相应广告以打开调试菜单。
- 选择打开广告检查器。
如果您没有关联设备,可能需要登录 Ad Manager 账号。
您也可以从调试设置中选择“广告检查器”设置,然后选择一个手势;日后,直接使用该手势即可打开广告检查器。
以编程方式启动
运行以下命令以启动广告检查器:
Swift
GADMobileAds.sharedInstance().presentAdInspector(from: viewController) { error in
// Error will be non-nil if there was an issue and the inspector was not displayed.
}
Objective-C
[GADMobileAds.sharedInstance presentAdInspectorFromViewController:viewController
completionHandler:^(NSError *error) {
// Error will be non-nil if there was an issue and the inspector was not displayed.
}];
此方法适用于以编程方式注册的测试设备。如需了解详情,请参阅启用测试设备。
确保启动时所用的视图控制器在屏幕上完全可见。例如,如果您调用了 viewDidAppear:
。如果传入的视图控制器正处于显示过程中(例如,在视图控制器函数 viewDidLoad
中调用启动),则无法显示广告检查器。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-25。
[null,null,["最后更新时间 (UTC):2025-08-25。"],[],[],null,["Select platform: [Android](/ad-manager/mobile-ads-sdk/android/ad-inspector/launch-ad-inspector \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/ad-inspector/launch-ad-inspector \"View this page for the iOS platform docs.\") [Unity](/ad-manager/mobile-ads-sdk/unity/ad-inspector/launch-ad-inspector \"View this page for the Unity platform docs.\") [Flutter](/ad-manager/mobile-ads-sdk/flutter/ad-inspector/launch-ad-inspector \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\nBefore you test your ad integration, you must launch ad inspector in your app.\nThis page covers how to launch ad inspector\nthrough the debug menu and how to launch\nprogrammatically.\n\nPrerequisites\n\nBefore you continue, do the following:\n\n- Complete all items in the initial [Prerequisites](/ad-manager/mobile-ads-sdk/ios/ad-inspector#prerequisites) to create an Ad Manager account, set your test device, initialize Google Mobile Ads SDK, and install the latest version.\n\nChoose a launch option\n\nYou can launch ad inspector in the following ways:\n\n- The launch button from the debug menu within your app to use the gesture that you selected in the ad inspector settings.\n- Programmatically through the Google Mobile Ads SDK.\n\nLaunch using the debug menu\n\nTo launch ad inspector through the debug menu, you don't require further\nchanges on your app. For more details, see\n[Inspect mobile app ad delivery](//support.google.com/admanager/answer/7180401).\n\nComplete the following steps:\n\n1. Find an ad served in your Ad Manager network.\n2. Touch and hold the ad to open the debug menu.\n3. Select **Open ad inspector**.\n\nIf you didn't [link your device](/ad-manager/mobile-ads-sdk/ios/debug#link_your_device), you might\nneed to sign in to your Ad Manager account.\n\nFrom the debug settings, you can also select **Ad inspector settings** and\nchoose a gesture that can open ad inspector.\n\nLaunch programmatically\n\nLaunch ad inspector by running the following: \n\nSwift \n\n MobileAds.shared.presentAdInspector(from: viewController) { error in\n // Error will be non-nil if there was an issue and the inspector was not displayed.\n }\n\nObjective-C \n\n [GADMobileAds.sharedInstance presentAdInspectorFromViewController:viewController\n completionHandler:^(NSError *error) {\n // Error will be non-nil if there was an issue and the inspector was not displayed.\n }];\n\nThis method works for test devices registered programmatically. For more details, see\n[Enable test devices](/ad-manager/mobile-ads-sdk/ios/test-ads#enable_test_devices).\n\nEnsure that the view controller to this launch is fully visible on screen. For\nexample, if you called `viewDidAppear:`. If the view controller passed in is\nin the process to display, such as when the launch is called in the view\ncontroller function `viewDidLoad`, the presentation of the ad inspector fails."]]