use javascrupt to know it is webview ? support node and the browser(webpack)
npm install js-is-webview --save
pass User-Agent sniffing,know the HTTP/HTTPS request is performed by a UIWebview/Webview or not.
const isWebview = require("js-is-webview");
const is_webview = new isWebview();
const server = (req, res, next) => {
- let userAgent = {
- userAgent:req.headers['User-Agent']
}
// if true
if(isWebview.check(userAgent))){
//...
next();
}
};
pass the browser features and properties,know it is webview or
const isWebview = require("js-is-webview");
const is_webview = new isWebview();
let userAgent = {
userAgent:navigator.userAgent
}
if(isWebview.check(userAgent))){
//...
}
userAgent
(Object.key): Browser User-Agent header string
if(isWebview.check({userAgent}))){
//...
}
userAgent
(Object.key): Browser User-Agent header stringconfigObject
(Object)appName
(String): the app name explicitly set in your WebView properties/settings.