3

I'm getting to grips with the functionality available in Chrome Custom Tabs and I'm curious to know how I might go about communicating between the Custom Tab and the app itself. I can see in CustomTabsSession that there are methods like requestPostMessageChannel, but it returns false every time I try to use it. I also can't find any documentation or examples about this.

Does anyone know how I'd go about successfully establishing a message channel between my native code and my Custom Tabs client? Bonus question: is it possible to postMessage to a service worker?

Alastair
  • 5,894
  • 7
  • 34
  • 61

1 Answers1

3

I just found the following Chromium patch from 2018:

https://chromium.googlesource.com/chromium/src/+/20891520570f780b13ae9725d9aa5a909338d0a9%5E%21/

Disable PostMessage on Trusted Web Activities.

Moving Trusted Web Activities over to CustomTabActivity gets us PostMessage for free. Unfortunately we're not ready to launch that, so disable it for the time being.

It's possible that things have changed since then, but this flag in Chrome 81 suggests it hasn't. So it might just not be possible to do this right now.

Alastair
  • 5,894
  • 7
  • 34
  • 61