HTML 인-앱 메시지
앱에 Braze 자바스크립트 인터페이스를 추가하는 방법을 알아보고, Braze API를 사용하여 사용자 지정 웹뷰에서 HTML 인앱 메시지를 생성할 수 있습니다.
Prerequisites
이 기능을 사용하려면 먼저 Android Braze SDK를 통합해야 합니다.
About HTML messages
With the Braze JavaScript interface, you can leverage Braze inside the custom WebViews within your app. The interface’s ScriptMessageHandler
is responsible for:
- Injecting the Braze JavaScript bridge into your WebView, as outlined in User Guide: HTML in-app messages.
- Passing the bridge methods received from your WebView to the Braze Android SDK.
Adding the interface to a WebView
Using Braze functionality from a WebView in your app can be done by adding the Braze JavaScript interface to your WebView. After the interface has been added, the same API available for User Guide: HTML in-app messages will be available within your custom WebView.
1
2
3
4
5
String javascriptString = BrazeFileUtils.getAssetFileStringContents(context.getAssets(), "braze-html-bridge.js");
myWebView.loadUrl("javascript:" + javascriptString);
final InAppMessageJavascriptInterface javascriptInterface = new InAppMessageJavascriptInterface(context, inAppMessage);
myWebView.addJavascriptInterface(javascriptInterface, "brazeInternalBridge");
1
2
3
4
5
val javascriptString = context.assets.getAssetFileStringContents("braze-html-bridge.js")
myWebView.loadUrl("javascript:" + javascriptString!!)
val javascriptInterface = InAppMessageJavascriptInterface(context, inAppMessage)
myWebView.addJavascriptInterface(javascriptInterface, "brazeInternalBridge")
Embedding YouTube content
YouTube and other HTML5 content can play in HTML in-app messages. This requires hardware acceleration to be enabled in the activity where the in-app message is being displayed; see the Android developer guide for more details. Hardware acceleration is only available on Android API versions 11 and later.
The following is an example of an embedded YouTube video in an HTML snippet:
1
2
3
4
5
6
7
8
9
<body>
<div class="box">
<div class="relativeTopRight">
<a href="appboy://close">X</a>
</div>
<iframe width="60%" height="50%" src="https://www.youtube.com/embed/_x45EB3BWqI">
</iframe>
</div>
</body>
guide/swift/in_app_messages/html_messages.md developer_ %}