capacitor-inappbrowser icon indicating copy to clipboard operation
capacitor-inappbrowser copied to clipboard

feat: ability to open more than 1 webview and post messages to all or only specific one

Open Albermonte opened this issue 2 months ago • 3 comments

Feature Request

Description

Right now if you open one webview on top of other it will overwrite the current one, resulting in not being able to communicate with more than 1 webview and when closing the last open webwiew the communication with the other webview wont be recovered.

I want to be able to open as many webviews as I want and being able to communicate with all of them in a broadcast like way or only with a specific one.

Platform(s)

iOS, Android

Preferred Solution

What I'm currently doing is assigning a random uuid to every new webview I open and returning that uuid with the openWebView method. If I want to broadcast a message to all the webviews I will just use postMessage without any id, but if I want to communicate with a specific webview I would do:

await InAppBrowser.postMessage({
  webViewId: uuid,
  detail: { message: 'Hello WebView!' }
});

Albermonte avatar Nov 12 '25 17:11 Albermonte

Image

Hi, this is a discussion we had internally not long-ago. We don't currently plan to add a feature like this, but we will keep in mind that there is interest in this feature.

WcaleNieWolny avatar Nov 13 '25 04:11 WcaleNieWolny

Would you be open for a PR with this feature (at least with the basics I need) that doesn't affect the current use of the plugin?

Albermonte avatar Nov 13 '25 09:11 Albermonte

Sure, I would be open for that

WcaleNieWolny avatar Nov 13 '25 13:11 WcaleNieWolny