I am working on an Android app that displays a Progressive Web App (PWA) through a Trusted Web Activity (TWA). The app uses scoped storage for security purposes.
I need to provide a way for the user to download a file on clicking a button from the PWA and save it to the app's scoped storage. However, I am having trouble figuring out how to do this.
I went through some SO answers which says postMessage() is disabled on trusted web activity so related answers goes out of the picture.
I tried to override the onNewIntent() method of the Android Browser Helper library's LauncherActivity class and registered an intent filter to intercept custom URL schemes that I can trigger from the web app (PWA). However, the application closes upon launching the said intent URL.
Need to find a solution for this. Any help is appreciated.