postMessage support?
See original GitHub issueI noticed the APIs in CustomTabService
for using postMessage, but I couldn’t get them to work. And after some searching around I found this patch, suggesting that postMessage
is disabled in TWAs:
https://chromium.googlesource.com/chromium/src/+/20891520570f780b13ae9725d9aa5a909338d0a9^!/
But it was back in 2018, so I wanted to check: can I use the native postMessage APIs with TWAs? If not, are there any other strategies for transferring data between the native and web sides?
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (3 by maintainers)
Top Results From Across the Web
"postMessage" | Can I use... Support tables for HTML5, CSS3 ...
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >Window.postMessage() - Web APIs | MDN
The window.postMessage() method safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it ...
Read more >What browsers support the window.postMessage call now?
All latest browsers supports that e.g. IE 11, Edge, Firefox 57+, Dafari 11+, iOS Safari 10.2 ...
Read more >Using JavaScript and window.postMessage() - In Plain English
window.postMessage() is a safe way to send messages between windows in different domains or origins. One can also post to an IFrame. The...
Read more >Attacking and Defending postMessage in HTML5 Websites
The postMessage mechanism in HTML5 enables Web content from different origins to communicate with each other, thus relaxing the same origin policy.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@andreban I need to implement background geolocation in my TWA. Since background geolocation is currently not supported in Web, I plan to implement it natively. But I need to somehow pass geolocation coordinates from native code to JavaScript code every X seconds. The first idea that came to my mind is to pass geolocation coordinates via URL query parameters. But looks like it’s not a good idea, because changing URL query parameters leads to page reload. Right? Moreover, actually I need to pass the data into service worker, not into the page (because this should work in the background). What is the best way to pass data from native code to JS code in my case? Any ideas and code samples will be appreciated.
@AlissonRS Did you find a way to get it to work?