Two way bridge between native android and progressive web apps in trusted web application

1.5k views Asked by At

As per current understanding from TWA documentation, we can pass message between native android and web using URL intents and query parameters/custom headers.

I want to pass information from web to native and return response based on the action to that message in native to web on the same page. I can do this by reopening another trusted web activity. But this leads to page load and destroys the existing state of the page.

In other words, I am trying to replicate a request-response type of behaviour in TWA without page transition on web.

Sample use case : From PWA, I want to call android native code to print a string. In case of failure cases, I want to send back the error response to PWA.

Is there a way this can be done without reloading the page?

1

There are 1 answers

0
andreban On

Trusted Web Activities don't have a runtime communication bridge between Android and the web app, so the short answer to the question is that this cannot be done without reloading the page.

There's a long discussion thread here: https://github.com/GoogleChrome/android-browser-helper/issues/55. Please, do chime in and describe your use case.