Braze JavaScript interface
This reference article shows how to add the Braze JavaScript Interface to WebViews.
Using Braze functionality from a WebView in your app can be done by adding the Braze JavaScript interface to your WebView. Once the interface has been added, the same API available for HTML in-app messages will be available within your custom WebView.
1
2
3
4
5
String javascriptString = BrazeFileUtils.getAssetFileStringContents(context.getAssets(), "appboy-html-in-app-message-javascript-component.js");
myWebView.loadUrl("javascript:" + javascriptString);
final InAppMessageHtmlJavascriptInterface javascriptInterface = new InAppMessageHtmlJavascriptInterface(context, inAppMessage);
myWebView.addJavascriptInterface(javascriptInterface, "brazeInternalBridge");
1
2
3
4
5
val javascriptString = BrazeFileUtils.getAssetFileStringContents(context.getAssets(), "appboy-html-in-app-message-javascript-component.js")
myWebView.loadUrl("javascript:" + javascriptString!!)
val javascriptInterface = InAppMessageHtmlJavascriptInterface(context, inAppMessage)
myWebView.addJavascriptInterface(javascriptInterface, "brazeInternalBridge")