تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تتيح واجهات برمجة التطبيقات الخاصة بعرض الإعلانات على الويب إتاحة إشارات التطبيقات للعلامات في WebView، ما يساعد في تحسين تحقيق الربح للناشرين الذين قدّموا المحتوى وحماية المعلِنين من الرسائل غير المرغوب فيها.
تساعد إشارات التطبيق هذه، مثل معرّف التطبيق وإصدار التطبيق، في تفعيل حالات استخدام إعداد التقارير واستهداف مستودع الإعلانات في المتصفّح داخل التطبيق التي لا تتوفّر عادةً إلا في زيارات التطبيق.
آلية العمل
لا يتم التواصل مع حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" إلا استجابةً لأحداث الإعلانات التي يتم تشغيلها من خلال أي مما يلي:
يضيف حزمة تطوير البرامج (SDK) معالجات الرسائل إلى WebView المسجَّل للاستماع إلى أحداث الإعلانات هذه. للحصول على فكرة أفضل عن طريقة عمل ذلك، يمكنك الاطّلاع على رمز المصدر الخاص بصفحة الاختبار.
المستوى 21 لواجهة برمجة التطبيقات في Android أو مستوى أحدث
أضِف علامة <meta-data> التالية في ملف AndroidManifest.xml لتجاوز عملية التحقّق من APPLICATION_ID. في حال عدم اتّباع هذه الخطوة وعدم تقديم العلامة <meta-data>، ستعرض حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" الخطأ IllegalStateException عند بدء تشغيل التطبيق.
يجب استدعاء
registerWebView()
في سلسلة التعليمات الرئيسية لإنشاء اتصال بمعالجات JavaScript في
رمز AdSense أو علامة الناشر من Google ضمن كل مثيل WebView. يجب إجراء ذلك في أقرب وقت ممكن، مثلاً في طريقة onCreate() الخاصة بـ MainActivity.
Kotlin
importandroid.webkit.CookieManagerimportandroid.webkit.WebViewimportcom.google.android.gms.ads.MobileAdsclassMainActivity:AppCompatActivity(){lateinitvarwebView:WebViewoverridefunonCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)webView=findViewById(R.id.webview)// Let the web view accept third-party cookies.CookieManager.getInstance().setAcceptThirdPartyCookies(webView,true)// Let the web view use JavaScript.webView.settings.javaScriptEnabled=true// Let the web view access local storage.webView.settings.domStorageEnabled=true// Let HTML videos play automatically.webView.settings.mediaPlaybackRequiresUserGesture=false// Register the web view.MobileAds.registerWebView(webView)}}
Java
importandroid.webkit.CookieManager;importandroid.webkit.WebView;importcom.google.android.gms.ads.MobileAds;publicclassMainActivityextendsAppCompatActivity{privateWebViewwebView;@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);webView=findViewById(R.id.webview);// Let the web view accept third-party cookies.CookieManager.getInstance().setAcceptThirdPartyCookies(webView,true);// Let the web view use JavaScript.webView.getSettings().setJavaScriptEnabled(true);// Let the web view access local storage.webView.getSettings().setDomStorageEnabled(true);// Let HTML videos play automatically.webView.getSettings().setMediaPlaybackRequiresUserGesture(false);// Register the web view.MobileAds.registerWebView(webView);}}
اختبار عملية الدمج
قبل استخدام عنوان URL الخاص بك، ننصحك بتحميل عنوان URL التالي لاختبار عملية الدمج:
يعرض عنوان URL التجريبي أشرطة حالة خضراء لعملية ربط ناجحة إذا استوفيت الشروط التالية:
WebView مرتبطة بحزمة "SDK لإعلانات Google على الأجهزة الجوّالة"
الخطوات التالية
جمع الموافقات في WebView لا تنقل واجهات برمجة التطبيقات الخاصة بعرض الإعلانات على الويب الموافقة التي تم جمعها في سياق التطبيق المتوافق مع الأجهزة الجوّالة باستخدام إطارَي التوافق الإصدار 2.0 من إطار الشفافية والموافقة الصادر عن مكتب IAB أو قانون خصوصية المستهلك في كاليفورنيا الصادر عن مكتب IAB إلى العلامات في عروض الويب. إذا كنت مهتمًا بتنفيذ مسار موافقة واحد بصفتك مالكًا لكلّ من WebView ومحتوى الويب المرتبط به والذي يتم تحقيق الربح منه، عليك العمل مع منصّة إدارة الموافقة لجمع الموافقة في سياق WebView.
تاريخ التعديل الأخير: 2025-09-05 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-05 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eThe Web View APIs for Ads enhance monetization for publishers and protect advertisers by making app signals available to web view ads.\u003c/p\u003e\n"],["\u003cp\u003eThese APIs leverage app signals like app ID and version to enable reporting and targeting capabilities previously limited to app traffic.\u003c/p\u003e\n"],["\u003cp\u003eTo integrate, register your web view with the Google Mobile Ads SDK (version 20.6.0 or higher) using \u003ccode\u003eMobileAds.registerWebView()\u003c/code\u003e after setting necessary web view configurations.\u003c/p\u003e\n"],["\u003cp\u003eTesting can be performed with the provided URL to confirm successful integration and connection between the web view and SDK.\u003c/p\u003e\n"],["\u003cp\u003ePublishers are responsible for managing consent within the web view context, as the API doesn't automatically propagate consent from the mobile app.\u003c/p\u003e\n"]]],["Web view APIs enable sharing app signals like app ID and version with tags in `WebView`, improving monetization and protecting advertisers. This is achieved through the Google Mobile Ads SDK listening for ad events from AdSense, Google Publisher Tag, or IMA for HTML5. Developers must register the `WebView` using `MobileAds.registerWebView()` in the app's `onCreate()` method and include a specific `\u003cmeta-data\u003e` tag in `AndroidManifest.xml`. Integration can be tested via a provided test URL. It is necessary to gather consent separately in the webview.\n"],null,["The web view APIs for ads makes app signals available to the tags in your\n\n[`WebView`](//developer.android.com/reference/android/webkit/WebView), helping to improve monetization for the\npublishers that provided the content and protect advertisers from spam.\n\nThese app signals, such as app ID and app version, help activate [Reporting](//support.google.com/admanager/answer/14137220#report-on-in-app-webview-traffic)\nand [Target in-app browser inventory](//support.google.com/admanager/answer/14137220#target-in-app-webview-inventory)\nuse cases that are otherwise only available on app traffic.\n\n\nHow it works\n\nCommunication with the Google Mobile Ads SDK only happens in response to ad\nevents triggered by any of the following:\n\n- [AdSense code](//support.google.com/adsense/answer/9274634)\n- [Google Publisher Tag](//support.google.com/admanager/answer/181073)\n- [IMA for HTML5](//support.google.com/adsense/answer/6391192)\n\nThe SDK adds message handlers to the registered `WebView` to listen for\nthese ad events. For a better sense of how this works, view the\n[source code](//github.com/google/webview-ads/blob/main/test/index.html) of the\ntest page.\n\nPrerequisites\n\n- [Google Mobile Ads SDK](/ad-manager/mobile-ads-sdk/android/quick-start#import_the_mobile_ads_sdk) version 20.6.0 or higher.\n- Android API level 21 or higher.\n\n- Add the following `\u003cmeta-data\u003e` tag in your `AndroidManifest.xml` file to\n bypass the check for the `APPLICATION_ID`. If you miss this step and don't\n provide the `\u003cmeta-data\u003e` tag, the Google Mobile Ads SDK throws an\n [`IllegalStateException`](//developer.android.com/reference/java/lang/IllegalStateException)\n on app start.\n\n \u003c!-- Bypass APPLICATION_ID check for web view APIs for ads --\u003e\n \u003cmeta-data\n android:name=\"com.google.android.gms.ads.INTEGRATION_MANAGER\"\n android:value=\"webview\"/\u003e\n\n\u003cbr /\u003e\n\nRegister the web view\n\nCall\n\n[`registerWebView()`](/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/MobileAds#registerWebView(android.webkit.WebView))\n\non the main thread to establish a connection with the JavaScript handlers in the\nAdSense code or Google Publisher Tag within each `WebView` instance. This\nshould be done as early as possible, such as in the\n\n`onCreate()` method of your `MainActivity`.\n\n\nKotlin \n\n import android.webkit.CookieManager\n import android.webkit.WebView\n import com.google.android.gms.ads.MobileAds\n\n class MainActivity : AppCompatActivity() {\n lateinit var webView: WebView\n\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_main)\n webView = findViewById(R.id.webview)\n\n // Let the web view accept third-party cookies.\n CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true)\n // Let the web view use JavaScript.\n webView.settings.javaScriptEnabled = true\n // Let the web view access local storage.\n webView.settings.domStorageEnabled = true\n // Let HTML videos play automatically.\n webView.settings.mediaPlaybackRequiresUserGesture = false\n\n // Register the web view.\n MobileAds.registerWebView(webView)\n }\n }\n\nJava \n\n import android.webkit.CookieManager;\n import android.webkit.WebView;\n import com.google.android.gms.ads.MobileAds;\n\n public class MainActivity extends AppCompatActivity {\n private WebView webView;\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n webView = findViewById(R.id.webview);\n\n // Let the web view accept third-party cookies.\n CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);\n // Let the web view use JavaScript.\n webView.getSettings().setJavaScriptEnabled(true);\n // Let the web view access local storage.\n webView.getSettings().setDomStorageEnabled(true);\n // Let HTML videos play automatically.\n webView.getSettings().setMediaPlaybackRequiresUserGesture(false);\n\n // Register the web view.\n MobileAds.registerWebView(webView);\n }\n }\n\nTest your integration\n\nBefore using your own URL, we recommend that you load the following URL to test\nthe integration: \n\n https://google.github.io/webview-ads/test#api-for-ads-tests\n\nThe test URL shows green status bars for a successful integration if the\nfollowing conditions apply:\n\n- `WebView` connected to the Google Mobile Ads SDK\n\nNext steps\n\n- Gather consent in `WebView`. The Web view APIs for Ads doesn't propagate consent collected in the mobile app context using [IAB TCF v2.0](//iabeurope.eu/tcf-2-0/) or [IAB CCPA](//iabtechlab.com/wp-content/uploads/2019/11/Technical-Specifications-FAQ-US-Privacy-IAB-Tech-Lab.pdf) compliance frameworks to the tags in your web views. If you're interested in implementing a single consent flow as the owner of both the `WebView` and its corresponding web content being monetized, work with your consent management platform to gather consent in the `WebView` context."]]