requestPostMessageChannel method

  1. @override
Future<bool> requestPostMessageChannel({
  1. required WebUri sourceOrigin,
  2. WebUri? targetOrigin,
})

Sends a request to create a two way postMessage channel between the client and the browser. If you want to specifying the target origin to communicate with, set the targetOrigin.

sourceOrigin - A origin that the client is requesting to be identified as during the postMessage communication. It has to either start with http or https.

targetOrigin - The target Origin to establish the postMessage communication with. This can be the app's package name, it has to either start with http or https.

Returns whether the implementation accepted the request. Note that returning true here doesn't mean an origin has already been assigned as the validation is asynchronous.

Officially Supported Platforms/Implementations:

Implementation

@override
Future<bool> requestPostMessageChannel(
    {required WebUri sourceOrigin, WebUri? targetOrigin}) async {
  Map<String, dynamic> args = <String, dynamic>{};
  args.putIfAbsent("sourceOrigin", () => sourceOrigin.toString());
  args.putIfAbsent("targetOrigin", () => targetOrigin.toString());
  return await channel?.invokeMethod<bool>(
          "requestPostMessageChannel", args) ??
      false;
}