Where is webkit.messageHandlers.UnityInAppBrowser?

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

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #11643
    nategametaco
    Participant

    I have read your readme and searched on here. Where is the JS that we should be using on the page itself? Where is: webkit.messageHandlers.UnityInAppBrowser.sendMessageFromJS?

    #11644
    PiotrPiotr
    Keymaster

    I don’t understand your question. What do you mean by “where is the JS”?

    #11646
    nategametaco
    Participant

    Where is the Javascript library? It’s not included in the package, nor is it a URL. How do we call JS that isn’t included or found? What is the URL or path to the JS library.

    #11648
    PiotrPiotr
    Keymaster

    Its not JS library but something injected by Apple APIs. You dont have to worry about including anything.

    #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, 9 months ago by nategametaco.
    #11670
    PiotrPiotr
    Keymaster

    Hey, this part looks good. Maybe you can try example JS communication scene – is it working for you?

    #11673
    nategametaco
    Participant

    It is not working for us. Again, I don’t know how: webkit.messageHandlers.UnityInAppBrowser.postMessage is supposed to work if the JS doesn’t have the library to actually call anything. What are we missing? Can you send us a working example along with the JS that you would load into a browser? (Not just the Unity side like in the included example in the package.) npacyga@gametaco.com

    • This reply was modified 3 years, 9 months ago by nategametaco.
    #11675
    PiotrPiotr
    Keymaster

    Hey,
    There is nothing more than in example.
    Open ExampleJavaScriptCommunicationScene, click on BrowserOpener and change a “Page To Open” to “https://www.kokosoft.pl/examples/inappbrowser_ver_2_0.html” (.eu domain might be not working – working on fixing redirection issue).
    I’ve just checked it on iOS14 and ping/pong messaging still works. Check source code of website for reference implementation.

    #11679
    nategametaco
    Participant

    Got it working now based off your example. The trick was the “window” object. Be sure to update your documentation. You need the reference to that dynamic object.

    How can I render a loading screen over the top of this web view? I want to have a better loading experience over the top of the web view, then hide it once the page is done loading. We were able to do this with another web view because we could render the web page in a game object or at least that was the container. Then I could put a custom load screen over that. Let me know if you have any tips on this. Thanks!

    #11687
    nategametaco
    Participant

    Bump.

    #11688
    PiotrPiotr
    Keymaster

    Only way I think it could be possible is with JS + some DOM manipulation, there is no any API for that.

    #11689
    nategametaco
    Participant

    With our last Web View component (that conflicted with the Facebook SDK, so switched to yours) I was able to do this. Can I get access to your code so I can add this functionality? I don’t expect you to add this feature for one person. That and I don’t mind sharing it back to you as a feature to your component. Would this be possible? Thanks! npacyga@gametaco.com

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.