Documentation
App Detection
Know when your website runs inside the app, and on which platform
Your website can ask whether it is running inside your WebToApp app, and whether that app is the iOS or Android version. Use it to hide "Download our app" banners, skip web-only features (web push, ads that aren’t allowed in apps), or show platform-specific instructions. It works in every app build — nothing to turn on in the dashboard.
The quick way
Every page in the app gets small helpers. In a normal browser they don’t exist, so check first:
const inApp = typeof window.WebToApp?.isMobileApp === 'function';
if (inApp) {
const platform = window.WebToApp.platform; // 'ios' | 'android', available immediately
// or, through the bridge:
const confirmed = await window.WebToApp.isMobileApp(); // true
const os = await window.WebToApp.getPlatform(); // 'ios' | 'android'
}With bridge messages
Send isMobileApp or getPlatform with a requestId; the app answers with a DOM event. In a browser nothing answers, so treat a short timeout as "not the app":
function askApp(type, eventName, timeoutMs = 500) {
return new Promise((resolve) => {
if (!window.FlutterWebView) return resolve(null); // not inside the app
const requestId = type + '-' + Date.now();
const timer = setTimeout(() => { window.removeEventListener(eventName, onAnswer); resolve(null); }, timeoutMs);
function onAnswer(event) {
if (event.detail.requestId !== requestId) return;
clearTimeout(timer);
window.removeEventListener(eventName, onAnswer);
resolve(event.detail);
}
window.addEventListener(eventName, onAnswer);
window.FlutterWebView.postMessage(JSON.stringify({ type, requestId }));
});
}
const app = await askApp('isMobileApp', 'WebToAppIsMobileApp');
// → { requestId, isMobileApp: true, platform: 'ios' } or null in a browser
const info = await askApp('getPlatform', 'WebToAppPlatform');
// → { requestId, platform: 'android' }Answers
| Message | Event | event.detail |
|---|---|---|
isMobileApp | WebToAppIsMobileApp | { requestId, isMobileApp: true, platform } |
getPlatform | WebToAppPlatform | { requestId, platform } — ios or android |
Tip: detect the app on the server too
Bridge answers only exist in the browser. If your server needs to know on the very first request (to skip ads or app banners before the page renders), open the app with a marker in its start URL, e.g. https://yoursite.com?isMobileApp=true, and remember it in a cookie. Keep the bridge check as the source of truth on later pages.