Ionic 5 / Capacitor: How to find out if app is running in browser or compiled as native app? - ionic-framework

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"]

Check Capacitor.getPlatform()
If returns web then it’s running as website, if returns ios or android then it’s native.
Or can also check Capacitor.isNativePlatform().
https://capacitorjs.com/docs/core-apis/web#getplatform

Related

Any cordova plugin to add WebAuthn API to Android WebView?

We've developed a cordova app that shows one of our websites (which is also accessible using a web browser).
Recently, FIDO2 authentication using WebAuthn has been added to that website. This works fine in the tested browsers (Chrome and Firefox), but not in our cordova application, as it uses Android WebView, which doesn't implement the WebAuthn API.
Does anybody know if there is any cordova plugin to add this API to Android WebView?
Is there any website with information about the Android WebView roadmap (bugs that will be fixed in next release, new features that will be added, ...)?
You're correct that Android WebView doesn't support WebAuthn in Android 13. We hope to address that in the Android 14 timeframe but, for now, you have to inject Javascript hooks and use a Javascript bridge to implement it. It's certainly possible to do but I'm not aware of any packaged solutions that do it.

How can I debug a Flutter Web App on Safari using the inspector?

I am using flutter to write a simple app, everything works fine on Android, iOS, and Chrome. (I've also tested on Firefox & Brave Browser, all's well).
However, on Safari (Mac & iOS), the flutter app gets stuck on the index.html file and does not load the PWA.
The error from the console on Safari Inspect
How can I know what the anonymous function in js_helper is, or what main.dart.js:57063 refers to?
Is there any way of building for web without minifying?
Has anybody encountered a scenario where everything works on all platforms except Safari?
Flutter Doctor
Log from console when running on local server
debug for safari is not supported yet
but for anyone with the same problem you could solve it by running the app on release mode
flutter run -d chrome --release
after that open with the same port on safari and everything should be fine
You won't be able to debug it directly on Safari, but if you just want to test your app in safari with localHost, you can use these steps :
Enable 'developer' menu in Safari from settings of Safari :
Then check on 'Disable Cross-Origin restrictions"
Now after running release version of web app in chrome, use same app's address in Safari, you will be able to test it. Ex. http://localhost:51155/
to run in release mode : flutter run -d chrome --release
Hope this helps!

Flutter app getting installed on Android TV but not opening, why?

My flutter application is running on an Android TV emulator in Android Studio, but it's not working on an actual Android TV (4.4.4).
minSdk version seems to be 16 in my flutter app. App gets installed in Android TV with no errors or any issues, but when try to open it nothing happens. Any help?
I don't know what else I should provide for more clarification, let me know if anything more needed like my whole code.
My issue resolved by making a release version with certificate added into app. The compiler build app version won't work with actual tv with my experience.
I didn't had a android tv with myself, so needed to goto a shop frequently for checking my app.

g-places-autocomplete not working on android build

I am creating app on ionic and used g-places-autocomplete for google place auto complete.
It works well on browser, but not working on app after I built it on android app via ionic build android command.
After debug with android test app, i got error that i have not add Referrer URL as per android strucuture which is "file_url//android_asset/XXXXX".
After i added above type of URL, it start working.

Appium and android stock browser

I have Samsung device with stock browser that called Internet.
The device is over 4.4 version.
I'm trying to remote debug the stock browser on a real device without success.
Already succeeded to remote debug chrome.
Is it possible on a real device and not on emulator?
The problem is just Samsung's stock browser
Hi!, Appium started to work with Android's stock browser (named.. Browser) since v1.3, the actual problem is the Samsung stock browser isn't Browser, it's Internet! These both apps are different (shame on Samsung!, not Appium guys fault). All other Android distributions that stock browser is Browser are working fine with Appium >= v1.3 as I've said before.
Emulator stock browser is Browser, that's why it's working for you on Emulator!
Why Appium doesn't work with Samsung's stock browser?
Appium are built to work with Chromium WebView (present on Chrome and Browser) , and Internet does not have it. So it doesn't work with Appium now, and probably won't work never, as Appium's maintainers does not have any interest to do the automation outside Chromium WebView. See this issue for more information: https://github.com/appium/appium/issues/4509
Ok, but how do I use Appium with Samsung devices?
So, the only solution is installing Chrome into your samsung device.
If you can't access the store to install the Chrome app, you can download and install manually the Chrome APK into your device (or other browser that uses Chromium webview, such as Chromium and ContentShell).
PS: ContentShell is basically only Chromium webview, without favorites, bookmarks and other common browser stuff, so it's pretty good for Appium testing.