android-browser-helper icon indicating copy to clipboard operation
android-browser-helper copied to clipboard

When calling TwaLauncher.launch() a blank screen is shown if could not connect to web app

Open aaronbond opened this issue 3 years ago • 1 comments

I may be missing something, but when i cannot connect to the web app for some reason the default behaviour appears to just show a blank screen. Is this expected behaviour?

i notice there's some documentation on offline scenarios here: https://developer.chrome.com/docs/android/trusted-web-activity/offline-first/#handle-offline-scenarios

but i'm not sure how to incorporate this with the TwaLauncher. is there anyway to set a LauncherActivity or perhaps a concept like "offline strategy" ?

aaronbond avatar Sep 17 '21 02:09 aaronbond

You web application should have a Service Worker that is installed on the first run and will manage offline access after that. Check this article on how to implement this on your PWA.

There is an edge case where the user may be offline when the application is run for the first time, and the PWA didn't have a chance to install the Service Worker. Instead of a blank page, the user would see the Chrome dinosaur page. The article you linked explains how to overcome that particular issue, and the solution described is to create your own LauncherActivity by extending the existing one and slightly modifying its behaviour.

andreban avatar Sep 17 '21 08:09 andreban