Documentation
JavaScript Bridge
Communicate with the native app layer
The JavaScript Bridge lets your web application send messages to the native Flutter app shell via window.FlutterWebView.postMessage(). Some features (such as GPS) send data back through a FlutterLocationResponse DOM event.
Core Syntax
// Check if running in Flutter app
if (window.FlutterWebView) {
window.FlutterWebView.postMessage(JSON.stringify({
type: 'messageType',
// ... additional data
}));
}Message Types
| Type | Direction | Description |
|---|---|---|
userId | Web → App | OneSignal login/logout (see OneSignal guide) |
userTags | Web → App | OneSignal user tags for segmentation |
showRewardedAd | Web → App | Show rewarded AdMob ad (see AdMob guide) |
getLocation | Web → App → Web | Device GPS; response on FlutterLocationResponse (see Device Location guide) |
Rewarded ad completion is not sent back to the website yet — only the show request is supported from JavaScript.
Platform Detection
You can detect if your site is running inside the WebToApp wrapper by checking for the FlutterWebView object on the window.