11import { Capacitor } from "@capacitor/core" ;
22
3- export function isChromium ( ) {
3+ export function isChromiumBrowser ( ) {
44 // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
55 if ( ! navigator . userAgentData ) {
66 console . log ( navigator . userAgent ) ;
77 return false ;
88 }
99
10- console . log ( navigator . userAgentData ) ;
1110 // https://learn.microsoft.com/en-us/microsoft-edge/web-platform/user-agent-guidance
1211 return navigator . userAgentData . brands . some ( ( brand ) => {
1312 return brand . brand == "Chromium" ;
@@ -28,36 +27,34 @@ export function isIOS() {
2827 return false ;
2928}
3029
31- export function isWeb ( ) {
30+ export function isCapacitorWeb ( ) {
3231 if ( Capacitor . isNativePlatform ( ) ) {
3332 return Capacitor . getPlatform ( ) === "web" ;
3433 }
35- if ( navigator . userAgentData ) {
36- return [ "Linux" , "macOS" , "Windows" ] . includes ( navigator . userAgentData . platform ) ;
37- }
34+ return false ;
3835}
3936
4037export function checkBrowserCompatibility ( ) {
41- const androidDevice = isAndroid ( ) ;
42- const iosDevice = isIOS ( ) ;
43- const web = isWeb ( ) ;
4438 const webSerial = "serial" in navigator ;
4539 const isNative = Capacitor . isNativePlatform ( ) ;
40+ const isChromium = isChromiumBrowser ( ) ;
4641
47- const compatible = isNative || ( web && webSerial && isChromium ( ) ) ;
42+ const compatible = isNative || ( webSerial && isChromium ) ;
4843
49- console . log ( "Android: " , androidDevice ) ;
50- console . log ( "iOS: " , iosDevice ) ;
51- console . log ( "Web: " , web ) ;
52- console . log ( "Web Serial: " , webSerial ) ;
44+ console . log ( "User Agent: " , navigator . userAgentData ) ;
5345 console . log ( "Native: " , isNative ) ;
46+ console . log ( "Chromium: " , isChromium ) ;
47+ console . log ( "Web Serial: " , webSerial ) ;
48+ console . log ( "Android: " , isAndroid ( ) ) ;
49+ console . log ( "iOS: " , isIOS ( ) ) ;
50+ console . log ( "Capacitor web: " , isCapacitorWeb ( ) ) ;
5451
5552 if ( compatible ) {
5653 return true ;
5754 }
5855
5956 let errorMessage = "" ;
60- if ( ! isChromium ( ) ) {
57+ if ( ! isChromium ) {
6158 errorMessage = "Betaflight app requires a Chromium based browser (Chrome, Chromium, Edge)." ;
6259 }
6360
0 commit comments