Capacitor Android app does not open external browser by default - android

It's a Capacitor app based on a React project. I have the opposite question to most people, it seems -- most ask how to get an external link (a link not from their domain) to open in their app. I ask how to open it outside the app, in a standard browser. Not that I prefer users to jump between applications, but, once the app opens up an external webpage, then the user can't get back into the app, since the external webpage doesn't provide a deep link back into the app. So it seems a lesser evil to necessitate jumping between applications.
What confuses me is that, based on others asking the opposite question, opening an external url in an external browser should be the default behavior, but my Android app does the reverse. The Capacitor ios app based on the same code correctly opens any external link in Safari. But my Android app opens it right inside the app, causing me to lose the app to the redirects. I didn't explicitly add any settings to result in this behavior. What gives?
Edit:
It helps to check out more simulators. The behavior occurred on a simulator, specifically the WXGA tablet with Android version 30, but not on all simulators, even those with version 30. The WXGA tablet seemed to close the app and run the web browser, since I couldn't find the app window anymore the moment the redirect to the webpage happened. It looked as if the app was running the browser content, but I now think the app was simply closed. I'm still confused why it does that, since most other simulators and the physical phone I tested on didn't behave that way.

Related

How to integrate the chrome[-like] browser as part of the Android app?

Our app is built on Qt-C++ which acts as a backend. For front end, we invoke browser command in a given platform (Windows, Mac, Linux). Now the Javascript of browser and the C++ of backend communicate via WebSockets. All the rendering happens fine and app works well.
[Note: It turns out that, Qt's Web-engine is not a good option due to its size and inflexibility.]
However in the case of mobile apps there are few concerns.
We cannot invoke the chrome browser as we do in Desktops, because the main app goes in background and brings the "Google Chrome" (browser) app in foreground
The default choice is Webview, but there are few limitations of it as noted here
Our app is not heavy in rendering. Though it requires playing of video and webrtc (which is available with some of the Android webviews).
What is the best solution when the android app requires the features of Google chrome browser app?
Related: Are there any ways to embed a browser in Android app?

TWA Fullscreen PWA for Chrome and Samsung Internet

I'm trying to turn my PWA (Progressive web Application) into an TWA (Trusted Web Acitivity) App for Android. In the beginning everything was working fine, until a user reported a problem to me.
He was unable to open the App at all, so we checked to see what could be the cause. Turns out he hasn't installed Google Chrome and is using Samsung Internet instead.
Now I did manage to get the App working with Samsung Internet so far, but with Samsung Internet the address-bar still appears.
There are a few tutorials to setup your TWA for Chrome OR Samsung Internet, but how can I combine these two? I guess we shouldn't force the user to download Chrome first. I haven't found any articles concerning this issue, so I'd be grateful if someone can link me some.
When using a Trusted Web Activity with the recommended android-browser-helper library, the application will check for an installed browser that supports Trusted Web Activity, giving preference to the user's preferred browser.
If there's no browser that supports the protocol available, it will fall back to using a Custom Tab and, if Custom Tabs is not available, open the browser.
The library also contains a WebView fallback for developers who prefer that to the Custom Tab / browser. A demo on how to use the WebView fallback is available here.
Regarding the Samsung Internet browsers, it added support for Trusted Web Activity in November 2020 (version 13.0.2.9). Currently, Chrome, Samsung Internet, Firefox, Edge and others support Trusted Web Activity, covering the vast majority of users. An updated list of browser support is maintained here.
After tons of wasted time trying to figure this out myself and lots of research I found this article:
https://medium.com/#firt/google-play-store-now-open-for-progressive-web-apps-ec6f3c6ff3cc
Where you can find this info:
TWAs work only with Chrome today, but the API might be also cloned by other browsers, such as Samsung Internet, Edge or Firefox in the future.
*UPDATE 2/4: The TWA works over the Android Custom Tab protocol that other browsers are currently implementing, so if the user doesn’t have Chrome or has changed the default browser, another browser might take precedence and open the TWA with the PWA content. More testing is needed to understand how it works.
What happens if the user has an older version of Chrome and installs the app from the Play Store? In this case, your PWA will appear as a Chrome Custom Tab, not in a completely standalone mode.
What that means in a nutshell: TWA's are actually useless, as long as you need your App to be compatible with a lot of different devices (like most do). I also noticed many Apps don't work if you disable Chrome on your Device, why I guess these are using TWA's too (and getting bad reviews on PlayStore instead).
So what I did was to dump away everything I did with TWA, and simply started using Cordova instead. It would have been great to have something like TWA's working just that simple, but as long as it's not working without having Chrome installed, there's no point in using it at all.
And not having this stated on https://developers.google.com directly, but fuzzy and unclear, has probably ended in the waste of time of many dev's and/or tons of Users being unable to use some Apps.
I just checked my TWA and it is working for particular browsers as follows:
Chrome without any problem
Edge on first launch shows message running in edge, later works as expected
Opera working as expected
Samsung browser - asks to open in browser, but works fine in browser. hides address bar if opened in browser
Firefox(once a best browser around ...) asks to open in browser, if opened it still shows address bar

Hybrid PWA: what browser does it run in once installed to home screen?

I'm new to mobile app development and progressive web apps, and I'm trying to understand something fairly fundamental about hybrid mobile apps.
Assume that I've built a PWA, that I'm using a framework (Ionic 3) which takes care of the app's "install to home screen" functionality (providing a manifest.json; displaying the web app install banner; etc.), and that my app is hosted at http://example.com.
An Android user navigates to that URL, sees the install banner, and installs the app to their home screen.
Then, they launch the app from the newly created icon on their home screen.
At that point: what browser is the app running in?
I've seen mention of something called WebView; is this the browser-like wrapper that serves as the runtime environment for my app?
Or something else?
(I'm essentially trying to confirm that my app, once installed to the home screen, will have access to all of the browser APIs that it needs. I may need to target Android 6 – so if the answer is different for that version than for Android 8, that would be very helpful information as well.)
One thing to clarify is that PWAs are not hybrid apps. They are running in standard browser environments with the options of hiding the browser chrome. A hybrid app is web technology that is packaged into a native app and deployed to the Play Store/App Store.
For the most part PWAs will open in whatever browser engine the user installed them with. The exception seems to be Firefox on Android Oreo when the PWA is installed via WebAPK. That seemed to run in Chrome even when launched from Firefox.
Ultimately you are building a website and you can not guarantee what browsers you users will have. Use proper feature detection to enable/disable features and when something critical isn't supported direct users to where they can get modern browsers.

launch native app from browser

My problem is that in my mobile nexus5 with chrome browser, I can launch a native application with a schema or go to another page if failed, everything works well. But in some other mobiles still with chrome browser (in my case, there are mobiles made by manufactories from China like Huawei, they custom their android system like the way HTC and Sumsung do), the browser seems like treating the schema as a http request and open it, and then shows this page cannot be displayed. And also my Javasript code in previous page cannot work anymore.
Is this a bug with chrome or because the android system is modified manufactory so that chrome cannot handle the schema correctly.

Is Android + PhoneGap/Cordova always a headache?

I've been developing a mobile app for both iOS and Android. Due to time/budget constraints, we initially selected PhoneGap/Cordova as mobile app framework so we could write once and deploy to both platforms.
This plan has worked fine for iOS, but we're finding that Android's browser/engine is kind-of a piece of garbage (to put it nicely). Every time we add a new feature, we find one more thing that the Android browser doesn't support, or only partially supports, or fully supports but will randomly fail from time to time, etc. Even once we code around the Android issues and get things working smoothly, test it on multiple devices/versions, and deploy a new app to the Android market, we immediately start getting emails and reports from customers who can't get the app to work on their device. We have them uninstall/reinstall, reboot their phone to clear the memory, etc., and their device still consistently fails (and by "fail", I mean it typically just freezes and/or won't respond to touch input - it usually doesn't crash, or anything). The app works fine for most people, but there are still quite a few devices that inexplicably fail.
I don't mean for this to be a rant, I'm trying to analyze whether the Android+PhoneGap path is the correct path for us. Specifically, I'd like to find out the following:
Are there people out there having success with an Android+PhoneGap app? or is Android+PhoneGap always going to be a problem on certain devices?
Am I likely to have more luck with a native Android app (I've never attempted one)? Or are multiple devices/versions always a problem on Android, even with a Native app?
1) Yes. There are are good apps which are based on Phonegap and works well in all devices.
2) It depends on what features of the Android you are going to use. Few versions that does not support some features that's available only to new version.
BTW, what is the minimum required version that you have selected for your app? I assume you are developing the app with Android as base version.
When creating a new Android project, you have to set the minimum required platform version. If you set something higher and use the app in a lower version which does not support the feature, results are going to be different.
After having worked with Android+Cordova for some time now, I have the following suggestions/comments for anyone thinking of going that direction.
Consider using Sencha Touch, or jQuery Mobile, or another mobile framework that has already coded around the Android-browser issues (which there are a LOT of). Consider not straying too far from the default styling that come with those frameworks. Simply styling a normal web page to look like a mobile app is a constant headache to get working on multiple versions of the stock Android browser.
Although the stock Android browser is garbage, Mobile Chrome is pretty nice. In Android 4.4, the Chrome engine becomes the default engine used by a webview of an Android app. If you don't like Sencha or jQuery Mobile or the like, you could hold off and just use a mobile web site for a while until Android 4.3 and below become insignificant. It's not hard to get things working on Mobile Chrome.
Even without Sencha/JQM, you can still muscle your way around the stock browser issues, but it's almost as frustrating as developing for IE6. Okay, maybe not that bad… but close.
I've started experimenting some with a native Android app, and, so far, it seems like less of a headache than building an app with Android+Cordova+lackOfSenchaOrJQMorTheLike. The things I've experimented with work pretty consistently among different Android versions. But I don't have much experience there, so I can't comment too much on a native Android app.

Categories

Resources