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 λ©μμ§ μ²λ¦¬ λ‘μ§ κ΅¬ν
Β
Β
Β