Web Ad

Integration from Android Native side

Before showing the ad on the web view, we need to setup the WebAd object. The WebAd object can help intowow SDK interact with the web view.

1. Initialize WebAd

Init the WebAd Object and register the object to the web view.

import com.intowow.sdk.WebAd;

private WebView mWebView = new WebView(context);
private WebAd mWebAd = new WebAd(context);

mWebAd.registerWebView(mWebView);

2. Check shouldInterceptRequest in WebViewClient

Override the shouldInterceptRequest and pass the intowow related url to intowow SDK. Our SDK will return the WebResourceResponse back to the WebView to insert the ad source.

mWebView.setWebViewClient(new WebViewClient() {
 @Override
 public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
     if (request.getUrl() != null && request.getUrl().toString() != null &&
         request.getUrl().toString().indexOf(WebAd.INTOWOW_PREFIX) != -1) {
         WebResourceResponse response = mWebAd.shouldInterceptRequest(view, request);
         if (response != null) {
             return response;
         }
     }
     return super.shouldInterceptRequest(view, request);
 }
});

3. Destroy WebAd if you no longer need to use it

Please destroy the instance when you no longer need to use it.

if(mWebAd != null) {
    mWebAd.unregisterWebView();
    mWebAd.destroy();
}

If you want to get more information, please refer to WebAd class.

Integration from Web side

Web

Please see the web side integration for the web view implement detail.

Last updated