Reply To: Where is webkit.messageHandlers.UnityInAppBrowser?

Welcome! Forums Unity Plugins In-App Web Browser Where is webkit.messageHandlers.UnityInAppBrowser? Reply To: Where is webkit.messageHandlers.UnityInAppBrowser?

#11666
nategametaco
Participant

We still haven’t gotten this to work. As far as we can tell we are following your example and readme. Any guidance is appreciated.

I have this code on the Unity side:

private void postMessage(string statusMessage) 
{
     Debug.Log("[WebViewManager].postMessage -- status: " + statusMessage);
}
_inAppBrowserBridge.onJSCallback.AddListener(postMessage);
_inAppBrowserBridge is set in the Unity Editor with the prefab in editor. 

Here is the code on the JS side:

thankYouClick() {
  const c = this;
  const { transactionId, method } = c.props;
  const { fromApp, depositAmount, hasBonusCashOffer } = c.state;
  const gameVersion = this.getParam('gameVersion');
  /** Set link to fire for unity web view messaging */
  const message = {
    status: 'success',
    total: depositAmount,
    method,
    hasBonusCashOffer,
    transactionId,
  };
  try {
    console.log({ message });
    webkit.messageHandlers.UnityInAppBrowser.postMessage(message);
  } catch (err) {
    console.log('Can not reach native code');
  }
}
  • This reply was modified 3 years, 4 months ago by nategametaco.