the object name for addWebMessageListener
Capture the global handler and remove it from the global object.
Set up event listener for incoming messages from the captured handler.
Optional
context: string = 'none'Send an initial ping message to the platform to establish communication. This is a fire-and-forget notification that signals the JavaScript side is ready. Only sends in top context (not in frames) and if the messaging interface is available.
true if ping was sent, false if in frame or interface not ready
Android shared messaging configuration for addWebMessageListener API. This class should be constructed once and then shared between features.
The following example shows all the fields that are required to be passed in:
Native integration
The native Android code should use addWebMessageListener to listen for messages:
The JavaScript side uses postMessage() to send messages, which the native side receives through the WebMessageListener. Responses from the native side are delivered through addEventListener on the captured handler.