تسجيل رقم تعريف معلومات استجابة الإعلان إلى Crashlytics
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
اختيار النظام الأساسي:
Android
iOS
Unity
Firebase
Crashlytics
هي أداة خفيفة الوزن لإعداد تقارير الأعطال في الوقت الفعلي، وتسهّل عليك إدارة
مشاكل الثبات في تطبيقك. توفّر عليك Crashlytics الوقت المستغرَق في تحديد المشاكل وحلّها من خلال
تجميع الأعطال بذكاء وإبراز الظروف التي أدّت إلى حدوثها.
يوضّح هذا الدليل كيفية دمج Crashlytics في مشروع Unity حتى تتمكّن من تسجيل أرقام تعريف استجابة الإعلان. في وقت لاحق، عند تحديد المشاكل وحلّها بشأن الأعطال في تطبيقك، يمكنك البحث عن أرقام تعريف استجابة الإعلانات واستخدام مركز مراجعة الإعلانات في AdMob للعثور على الإعلانات وحظرها.
الخطوة 1: إضافة Firebase إلى تطبيق Unity
اتّبِع دليل دمج Firebase مع Unity لدمج Firebase Crashlytics مع Unity.
الخطوة 2: تسجيل معرّف استجابة الإعلان
أنشئ نصًا برمجيًا من نوع MonoBehaviour وأعِد ضبط كلّ من حزمتَي تطوير البرامج (SDK) في AdMob وFirebase.
استخدِم القيمة المنطقية isCrashlyticsInitialized
لتتبُّع وقت بدء عملية تهيئة Crashlytics.
using GoogleMobileAds.Api;
using Fabric.Crashlytics;
...
public class GameObjectScript : MonoBehaviour
{
bool isCrashlyticsInitialized = false;
public void Start()
{
....
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(initStatus => { });
....
// Initialize Firebase
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
Firebase.DependencyStatus dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;
isCrashlyticsInitialized = true;
}
else
{
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}",dependencyStatus));
// Firebase Unity SDK is not safe to use here.
}
}
}
}
طلب إعلان بانر
using GoogleMobileAds.Api;
using Fabric.Crashlytics;
...
public class GameObjectScript : MonoBehaviour
{
public void Start()
{
...
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(initStatus => { });
// Initialize Firebase.
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
Firebase.DependencyStatus dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
// Create and hold a reference to your FirebaseApp,
// where app is a Firebase.FirebaseApp property of your
// application class.
// Crashlytics will use the DefaultInstance, as well;
// this ensures that Crashlytics is initialized.
Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;
isCrashlyticsInitialized = true;
}
else
{
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}",dependencyStatus));
// Firebase Unity SDK is not safe to use here.
}
});
// Request Banner View.
this.RequestBanner();
...
}
public void RequestBanner()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3940256099942544/6300978111";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-1220882738324941/1255739139";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the top of the screen.
this.bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
AdRequest request = new AdRequest();
this.bannerView.LoadAd(request);
// Called when an ad request has successfully loaded.
this.bannerView.OnAdLoaded += this.HandleOnAdLoaded;
}
}
احصل على العنصر ResponseInfo
OnAdLoaded
وسجِّل معرّف الاستجابة في Crashlytics.
public void HandleOnAdLoaded(object sender, EventArgs args)
{
ResponseInfo responseInfo = this.bannerView.GetResponseInfo();
if (responseInfo != null)
{
String adResponseId = responseInfo.GetResponseId();
// Log to Crashlytics.
if (isCrashlyticsInitialized)
{
Crashlytics.SetCustomKey("banner_ad_response_id", adResponseId);
}
}
}
هذا كل شيء! يمكنك الآن الاطّلاع على أحدث banner_ad_response_id
في قسم المفتاح
ضمن جلسات الأعطال في لوحة بيانات Crashlytics. يُرجى العِلم أنّ ظهور بعض المفاتيح في لوحة البيانات قد يستغرق ما يصل إلى أربع ساعات.

إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-08-25 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-25 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eFirebase Crashlytics is a real-time crash reporter that simplifies app stability management by grouping crashes and highlighting their root causes.\u003c/p\u003e\n"],["\u003cp\u003eThis guide explains how to integrate Crashlytics into a Unity project to log ad response IDs for debugging purposes using the Ad Review Center in AdMob.\u003c/p\u003e\n"],["\u003cp\u003eImplementation involves initializing Firebase and AdMob SDKs, requesting a banner ad, and logging the ad response ID to Crashlytics upon successful ad load.\u003c/p\u003e\n"],["\u003cp\u003eLogged ad response IDs will appear on the Crashlytics dashboard, enabling developers to identify and address problematic ads.\u003c/p\u003e\n"]]],[],null,["# Logging Ad Response Info ID to Crashlytics\n\nSelect platform: [Android](/ad-manager/mobile-ads-sdk/android/crashlytics \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/crashlytics \"View this page for the iOS platform docs.\") [Unity](/ad-manager/mobile-ads-sdk/unity/crashlytics \"View this page for the Unity platform docs.\")\n\n\u003cbr /\u003e\n\n[Firebase\nCrashlytics](//firebase.google.com/docs/crashlytics/get-started?platform=unity)\nis a lightweight, realtime crash reporter that makes it easy for you to manage\nstability issues in your app. Crashlytics saves you troubleshooting time by\nintelligently grouping crashes and highlighting the circumstances that lead up\nto them.\n\nThis guide describes how to integrate Crashlytics into your Unity project so\nthat you can log ad response IDs. Later, when you troubleshoot crashes in your\napp, you can look up the ad response IDs and use the [Ad Review Center in\nAdMob](//support.google.com/admob/answer/3500252) to find and block the ads.\n\nStep 1: Add Firebase to your Unity app\n--------------------------------------\n\nFollow the [Firebase Unity integration\nguide](//firebase.google.com/docs/crashlytics/get-started?platform=unity) to\nintegrate Firebase Crashlytics into Unity.\n\nStep 2: Log the ad response ID\n------------------------------\n\n1. Create a MonoBehaviour script and initialize both AdMob and Firebase SDKs.\n Use the boolean `isCrashlyticsInitialized` to monitor when Crashlytics\n initializes.\n\n using GoogleMobileAds.Api;\n using Fabric.Crashlytics;\n ...\n public class GameObjectScript : MonoBehaviour\n {\n bool isCrashlyticsInitialized = false;\n public void Start()\n {\n ....\n // Initialize the Google Mobile Ads SDK.\n MobileAds.Initialize(initStatus =\u003e { });\n ....\n // Initialize Firebase\n Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =\u003e {\n Firebase.DependencyStatus dependencyStatus = task.Result;\n if (dependencyStatus == Firebase.DependencyStatus.Available)\n {\n Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;\n isCrashlyticsInitialized = true;\n }\n else\n {\n UnityEngine.Debug.LogError(System.String.Format(\n \"Could not resolve all Firebase dependencies: {0}\",dependencyStatus));\n // Firebase Unity SDK is not safe to use here.\n }\n }\n }\n }\n\n2. Request a banner ad.\n\n using GoogleMobileAds.Api;\n using Fabric.Crashlytics;\n ...\n public class GameObjectScript : MonoBehaviour\n {\n\n public void Start()\n {\n ...\n // Initialize the Google Mobile Ads SDK.\n MobileAds.Initialize(initStatus =\u003e { });\n\n // Initialize Firebase.\n Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =\u003e {\n Firebase.DependencyStatus dependencyStatus = task.Result;\n if (dependencyStatus == Firebase.DependencyStatus.Available)\n {\n // Create and hold a reference to your FirebaseApp,\n // where app is a Firebase.FirebaseApp property of your\n // application class.\n // Crashlytics will use the DefaultInstance, as well;\n // this ensures that Crashlytics is initialized.\n Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;\n isCrashlyticsInitialized = true;\n }\n else\n {\n UnityEngine.Debug.LogError(System.String.Format(\n \"Could not resolve all Firebase dependencies: {0}\",dependencyStatus));\n // Firebase Unity SDK is not safe to use here.\n }\n });\n\n // Request Banner View.\n this.RequestBanner();\n ...\n }\n public void RequestBanner()\n {\n #if UNITY_ANDROID\n string adUnitId = \"ca-app-pub-3940256099942544/6300978111\";\n #elif UNITY_IPHONE\n string adUnitId = \"ca-app-pub-1220882738324941/1255739139\";\n #else\n string adUnitId = \"unexpected_platform\";\n #endif\n // Create a 320x50 banner at the top of the screen.\n this.bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);\n AdRequest request = new AdRequest();\n this.bannerView.LoadAd(request);\n // Called when an ad request has successfully loaded.\n this.bannerView.OnAdLoaded += this.HandleOnAdLoaded;\n }\n }\n\n3. Get the `ResponseInfo` object `OnAdLoaded` and log the response ID to\n Crashlytics.\n\n public void HandleOnAdLoaded(object sender, EventArgs args)\n {\n ResponseInfo responseInfo = this.bannerView.GetResponseInfo();\n if (responseInfo != null)\n {\n String adResponseId = responseInfo.GetResponseId();\n // Log to Crashlytics.\n if (isCrashlyticsInitialized)\n {\n Crashlytics.SetCustomKey(\"banner_ad_response_id\", adResponseId);\n }\n }\n }\n\nThat's it! You can now see the most recent `banner_ad_response_id` in the key\nsection of crash sessions on your Crashlytics dashboard. Note that some keys may\ntake up to four hours to become visible on your dashboard."]]