বিজ্ঞাপনের জন্য WebView API একত্রিত করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
বিজ্ঞাপনের জন্য ওয়েব ভিউ APIগুলি আপনার WKWebView- এ ট্যাগগুলিতে অ্যাপ সিগন্যাল উপলব্ধ করে, যা প্রকাশকদের জন্য নগদীকরণ উন্নত করতে সাহায্য করে যারা সামগ্রী প্রদান করে এবং বিজ্ঞাপনদাতাদের স্প্যাম থেকে রক্ষা করে। এই অ্যাপ সিগন্যালগুলি, যেমন অ্যাপ আইডি এবং অ্যাপ সংস্করণ, রিপোর্টিং সক্রিয় করতে সাহায্য করে এবং অ্যাপ-মধ্যস্থ ব্রাউজার ইনভেন্টরি ব্যবহারের ক্ষেত্রে লক্ষ্য করে যা অন্যথায় শুধুমাত্র অ্যাপ ট্র্যাফিকের জন্য উপলব্ধ।

এটা কিভাবে কাজ করে
Google মোবাইল বিজ্ঞাপন SDK-এর সাথে যোগাযোগ শুধুমাত্র নিম্নলিখিতগুলির যেকোনো একটি দ্বারা ট্রিগার করা বিজ্ঞাপন ইভেন্টগুলির প্রতিক্রিয়া হিসাবে ঘটে:
এই বিজ্ঞাপন ইভেন্টগুলি শোনার জন্য SDK নিবন্ধিত WKWebView
এ বার্তা হ্যান্ডলার যোগ করে৷ এটি কীভাবে কাজ করে তার আরও ভাল ধারণার জন্য, পরীক্ষার পৃষ্ঠার উত্স কোডটি দেখুন।
পূর্বশর্ত
- Google মোবাইল বিজ্ঞাপন SDK সংস্করণ 9.6.0 বা উচ্চতর।
নিম্নলিখিত কী এবং স্ট্রিং মান দিয়ে Info.plist
ফাইলটি আপডেট করুন। এটি একটি GADApplicationIdentifier
মানের জন্য Google Mobile Ads SDK যে চেকটি করে তা বাইপাস করে যা ডেভেলপারদের ক্ষেত্রে প্রযোজ্য যারা ওয়েব ভিউয়ের বাইরে বিজ্ঞাপনগুলি প্রয়োগ করে৷ আপনি যদি এই ধাপটি মিস করেন এবং একটি GADApplicationIdentifier
প্রদান না করেন, Google Mobile Ads SDK অ্যাপ শুরুতে একটি GADInvalidInitializationException
নিক্ষেপ করে৷
<!-- Indicate
Google Mobile Ads SDK
usage is only for web view APIs for ads -->
<key>GADIntegrationManager</key>
<string>webview</string>
ওয়েব ভিউ নিবন্ধন করুন
প্রতিটি WKWebView
দৃষ্টান্তের মধ্যে AdSense কোড বা Google প্রকাশক ট্যাগে জাভাস্ক্রিপ্ট হ্যান্ডলারদের সাথে সংযোগ স্থাপন করতে মূল থ্রেডে কল register(_:)
এটি যত তাড়াতাড়ি সম্ভব করা উচিত, যেমন আপনার ভিউ কন্ট্রোলারের viewDidLoad
পদ্ধতিতে।
সুইফট
import WebKit
class ViewController: UIViewController {
var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Initialize a WKWebViewConfiguration object.
let webViewConfiguration = WKWebViewConfiguration()
// Let HTML videos with a "playsinline" attribute play inline.
webViewConfiguration.allowsInlineMediaPlayback = true
// Let HTML videos with an "autoplay" attribute play automatically.
webViewConfiguration.mediaTypesRequiringUserActionForPlayback = []
// Initialize the WKWebView with your WKWebViewConfiguration object.
webView = WKWebView(frame: view.frame, configuration: webViewConfiguration)
view.addSubview(webView)
// Register the web view.
MobileAds.shared.register(webView)
}
}
উদ্দেশ্য-C
@import WebKit;
#import "ViewController.h"
@interface ViewController ()
@property(nonatomic, strong) WKWebView *webView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Initialize a WKWebViewConfiguration object.
WKWebViewConfiguration *webViewConfiguration = [[WKWebViewConfiguration alloc] init];
// Let HTML videos with a "playsinline" attribute play inline.
webViewConfiguration.allowsInlineMediaPlayback = YES;
// Let HTML videos with an "autoplay" attribute play automatically.
webViewConfiguration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
// Initialize the WKWebView with your WKWebViewConfiguration object.
self.webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:webViewConfiguration];
[self.view addSubview:self.webView];
// Register the web view.
[GADMobileAds.sharedInstance registerWebView:self.webView];
}
আপনার ইন্টিগ্রেশন পরীক্ষা করুন
আপনার নিজের URL ব্যবহার করার আগে, আমরা সুপারিশ করি যে আপনি ইন্টিগ্রেশন পরীক্ষা করতে নিম্নলিখিত URL লোড করুন:
https://google.github.io/webview-ads/test/#api-for-ads-tests
নিম্নলিখিত শর্তগুলি প্রযোজ্য হলে পরীক্ষার URL একটি সফল ইন্টিগ্রেশনের জন্য সবুজ স্থিতি বার দেখায়:
-
WKWebView
Google মোবাইল বিজ্ঞাপন SDK-এর সাথে সংযুক্ত
পরবর্তী পদক্ষেপ
-
WKWebView
এ সম্মতি সংগ্রহ করুন। বিজ্ঞাপনের জন্য ওয়েব ভিউ APIs আপনার ওয়েব ভিউতে ট্যাগগুলিতে IAB TCF v2.0 বা IAB CCPA কমপ্লায়েন্স ফ্রেমওয়ার্ক ব্যবহার করে মোবাইল অ্যাপের প্রেক্ষাপটে সংগৃহীত সম্মতি প্রচার করে না। আপনি যদি WKWebView
এবং এর সংশ্লিষ্ট ওয়েব সামগ্রী উভয়ের মালিক হিসাবে একটি একক সম্মতি প্রবাহ বাস্তবায়নে আগ্রহী হন, তাহলে WKWebView
প্রসঙ্গে সম্মতি সংগ্রহ করতে আপনার সম্মতি ব্যবস্থাপনা প্ল্যাটফর্মের সাথে কাজ করুন।
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-08-23 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-08-23 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThe Web View APIs for Ads enable app signals to be available to ad tags within your WKWebView, enhancing monetization for publishers and protecting advertisers from spam.\u003c/p\u003e\n"],["\u003cp\u003eThese signals, such as app ID and version, unlock functionalities like reporting and targeted in-app browser inventory, previously exclusive to app traffic.\u003c/p\u003e\n"],["\u003cp\u003eTo utilize the APIs, you must register your WKWebView with the Google Mobile Ads SDK (version 9.6.0 or higher) and update your Info.plist file.\u003c/p\u003e\n"],["\u003cp\u003eThe SDK establishes communication with JavaScript handlers in your ad code (AdSense, Google Publisher Tag, or IMA for HTML5) solely during ad events.\u003c/p\u003e\n"],["\u003cp\u003eEnsure to gather user consent within the WKWebView context as the APIs do not automatically propagate consent collected in the mobile app using IAB frameworks.\u003c/p\u003e\n"]]],[],null,["The web view APIs for ads makes app signals available to the tags in your\n\n[WKWebView](//developer.apple.com/documentation/webkit/wkwebview), 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 `WKWebView` 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| **Warning:** Don't call [`removeAllScriptMessageHandlers()`](//developer.apple.com/documentation/webkit/wkusercontentcontroller/3585114-removeallscriptmessagehandlers) from your `WKWebView` instance as this has unintended side effects. If needed, call [`removeScriptMessageHandler(forName:)`](//developer.apple.com/documentation/webkit/wkusercontentcontroller/1537532-removescriptmessagehandler) to remove individual message handlers instead.\n\nPrerequisites\n\n- [Google Mobile Ads SDK](/ad-manager/mobile-ads-sdk/ios/quick-start#import_the_mobile_ads_sdk) version 9.6.0 or higher.\n- Update the `Info.plist` file with the following key and string value. This\n bypasses a check the Google Mobile Ads SDK does for a\n `GADApplicationIdentifier` value that applies to developers who implement ads\n outside of a web view. If you miss this step and don't provide a\n `GADApplicationIdentifier`, the Google Mobile Ads SDK throws a\n `GADInvalidInitializationException` on app start.\n\n \u003c!-- Indicate Google Mobile Ads SDK usage is only for web view APIs for ads --\u003e\n \u003ckey\u003eGADIntegrationManager\u003c/key\u003e\n \u003cstring\u003ewebview\u003c/string\u003e\n\n\u003cbr /\u003e\n\nRegister the web view\n\nCall\n\n[`register(_:)`](/admob/ios/api/reference/Classes/GADMobileAds#-registerwebview:)\n\non the main thread to establish a connection with the JavaScript handlers in the\nAdSense code or Google Publisher Tag within each `WKWebView` instance. This\nshould be done as early as possible, such as in the\n\n`viewDidLoad` method of your view controller.\n\n\nSwift \n\n import WebKit\n\n class ViewController: UIViewController {\n\n var webView: WKWebView!\n\n override func viewDidLoad() {\n super.viewDidLoad()\n\n // Initialize a WKWebViewConfiguration object.\n let webViewConfiguration = WKWebViewConfiguration()\n // Let HTML videos with a \"playsinline\" attribute play inline.\n webViewConfiguration.allowsInlineMediaPlayback = true\n // Let HTML videos with an \"autoplay\" attribute play automatically.\n webViewConfiguration.mediaTypesRequiringUserActionForPlayback = []\n\n // Initialize the WKWebView with your WKWebViewConfiguration object.\n webView = WKWebView(frame: view.frame, configuration: webViewConfiguration)\n view.addSubview(webView)\n\n // Register the web view.\n MobileAds.shared.register(webView)\n }\n }\n\nObjective-C \n\n @import WebKit;\n\n #import \"ViewController.h\"\n\n @interface ViewController ()\n\n @property(nonatomic, strong) WKWebView *webView;\n\n @end\n\n @implementation ViewController\n\n - (void)viewDidLoad {\n [super viewDidLoad];\n\n // Initialize a WKWebViewConfiguration object.\n WKWebViewConfiguration *webViewConfiguration = [[WKWebViewConfiguration alloc] init];\n // Let HTML videos with a \"playsinline\" attribute play inline.\n webViewConfiguration.allowsInlineMediaPlayback = YES;\n // Let HTML videos with an \"autoplay\" attribute play automatically.\n webViewConfiguration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;\n\n // Initialize the WKWebView with your WKWebViewConfiguration object.\n self.webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:webViewConfiguration];\n [self.view addSubview:self.webView];\n\n // Register the web view.\n \\[GADMobileAds.sharedInstance registerWebView:self.webView\\];\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- `WKWebView` connected to the Google Mobile Ads SDK\n\nNext steps\n\n- Gather consent in `WKWebView`. 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 `WKWebView` and its corresponding web content being monetized, work with your consent management platform to gather consent in the `WKWebView` context."]]