React Native WebView Invoke onMessage


#1
<WebView
source={{ uri: url1 }}
style={{ flex: 1 }}
onMessage={this.onMessage}
/>

url1 will redirect to url2 after completing a payment. The question is how can invoke onMessage in url2? I tried window.postMessage in url2, but that did not invoke the Webview onMessage that is on the client-side. What am I missing here?

The html in my url2 is like following:

<DOCTYPE html>
<html>
  <body>
    <div>
      <button id="event">Go Back</button>
    </div>
  </body>
  <script>
    document.getElementById('event').addEventListener('click', function() {
      window.postMessage('string', '*')}, false);
  </script>
</html>