I just want to know, if my Ionic 5 app is running in a browser, or in the webview of a compiled app.
Platform does not work: https://ionicframework.com/docs/angular/platform
It just tells about the device. But when I run it in chrome on an android device, it returns the same platforms as when I run it compiled.
Analysing the URL to check if it the webview url works, but not when using capacitor live reload. Because than it is the same URL like locally in the browser. And by the way, analysing the URL feels like an ugly solution.
Is it really that hard to get this simple and important information, or do I just miss something?
Edit:
Platform output
Chrome in Ubuntu with ionic serve: ["desktop"]
Chrome in Android: ["android", "mobile", "mobileweb"]
Android with capacitor livereload: ["android", "phablet", "mobile", "mobileweb"]
Android compiled: ["android", "phablet", "cordova", "capacitor", "mobile", "hybrid"]
platforms()
method (ionicframework.com/docs/angular/platform#platforms-string-) on both scenarios? That method returns a list of platforms, so it'd be useful to see if there's any difference (or if there's a bug in Ionic). – Gilbertsonconst isBrowser = platform.is('mobileweb') || platform.is('desktop')
and it should work, right? That way you'd know if the app is running natively or in a browser. – Gilbertsonionic capacitor run
will do the following: Perform ionic build (or run the dev server from ionic serve with the --livereload option). So the live reload flag will just run the dev server but on the device. I don't use it very often tbh but I guess it's useful when dealing with iOS and the top/bottom safe area insets for example. Could you please try to call a native plugin when using livereload to see what happens? – Gilbertson