BuzzAd-Benefit SDK μΈν„°μŠ€ν‹°μ…œ(Interstitial)을 WebView둜 μ—°λ™ν•˜κΈ°

이 λ¬Έμ„œλŠ” WebView에 κ΅¬ν˜„ν•œ λ²„νŠΌμ„ 톡해 Android λ˜λŠ” iOSμ—μ„œ μΈν„°μŠ€ν‹°μ…œ 지면을 μ‹€ν–‰μ‹œν‚€λŠ” 방법을 μ„€λͺ…ν•©λ‹ˆλ‹€.

κ°œμš”

μ•„λž˜ κ°€μ΄λ“œμ˜ 쀀비와 같이 Web에 λ²„νŠΌμ„ κ΅¬ν˜„ν•œ ν›„, Androidμ—μ„œ κ΅¬ν˜„ ν˜Ήμ€ iOSμ—μ„œ κ΅¬ν˜„μ„ μ°Έκ³ ν•˜μ—¬ 각각의 ν”Œλž«νΌμ—μ„œ μΈν„°μŠ€ν‹°μ…œ 지면을 ν‘œμ‹œν•  수 μžˆμŠ΅λ‹ˆλ‹€.

μ€€λΉ„

μš°μ„  WebViewμ—μ„œ μΈν„°μŠ€ν‹°μ…œ 지면을 ν‘œμ‹œν•˜κΈ° μœ„ν•œ λ²„νŠΌμ„ κ΅¬ν˜„ν•©λ‹ˆλ‹€.

<html> <head> <meta name='viewport' content='width=device-width, initial-scale=1.0'> <title>TEST</title> </head> <body> <input type='button' onClick='showInterstitial()' value='show interstitial' /> <script type='text/javascript'> const showInterstitial = () => { var userAgent = navigator.userAgent; if (/android/i.test(userAgent)) { BuzzAdBenefitJSBridge.showInterstitial() } if (/iPad|iPhone|iPod/.test(userAgent)) { webkit.messageHandlers.BuzzAdBenefitJSBridge.postMessage('showInterstitial') } } </script> </body> </html>

Β 

Androidμ—μ„œ κ΅¬ν˜„

Step 1. interface μ •μ˜

public interface BuzzAdBenefitJSBridge { void showInterstitial(); }

Β 

Step 2. JavascriptInterface μΆ”κ°€ 및 showInterstitial κ΅¬ν˜„

public class WebToInterstitialActivity extends AppCompatActivity implements BuzzAdBenefitJSBridge { private WebView webView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_web_to_interstitial); webView = findViewById(R.id.webView); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setUseWideViewPort(true); webView.addJavascriptInterface(this, "BuzzAdBenefitJSBridge"); webView.loadUrl("YOUR_URL"); } final BuzzAdInterstitial buzzAdInterstitial = new BuzzAdInterstitial.Builder(YOUR_INTERSTITIAL_UNIT_ID).buildDialog(); @Override @JavascriptInterface public void showInterstitial() { new Handler(getMainLooper()).post(new Runnable() { @Override public void run() { buzzAdInterstitial.load(new InterstitialAdListener() { @Override public void onAdLoadFailed(@Nullable AdError adError) { } @Override public void onAdLoaded() { buzzAdInterstitial.show(WebToInterstitialActivity.this); } }); } }); } }

iOS μ—μ„œ κ΅¬ν˜„

Step 1. interface μ •μ˜

Β 

Step 2. ScriptMessageHandler μΆ”κ°€ 및 showInterstitial λ©”μ‹œμ§€ 처리 둜직 κ΅¬ν˜„

Β 

Β 

Β