send message from JS not working on some ios devices

Welcome! Forums Unity Plugins In-App Web Browser send message from JS not working on some ios devices

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #566
    mirimad
    Participant

    I have used this great plugin in my unity app. It is working great on android devices. But on ios devices it is working on some and not on some.

    Idea is that I think it is not working on ios 11.

    Here is my website code:

    <script>
    $(document).ready(function () {
    $(“#home”).click(function () {
    if (isIOS()) {
    appendIframeWithURL(‘inappbrowserbridge://’ + “Go Home”);
    } else if (isAndroid()){
    UnityInAppBrowser.sendMessageFromJS(“Go Home”);
    }
    });
    });
    </script>

    <script type=”text/javascript”>

    function appendIframeWithURL(url) {
    var iframe = document.createElement(“IFRAME”);
    iframe.setAttribute(“src”, url);
    document.documentElement.appendChild(iframe);
    iframe.parentNode.removeChild(iframe);
    iframe = null;
    }

    var userAgent = navigator.userAgent || navigator.vendor || window.opera;
    function isIOS() {
    if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
    return true;
    } else {
    return false;
    }
    }
    function isAndroid() {
    return (/android/i.test(userAgent));
    }
    </script>

    #571
    PiotrPiotr
    Keymaster

    Hi,
    I’ve just checked sample scene on iOS 11.1.2 and see no difference – alert('pong') is executed. Is it working for you?

    #572
    mirimad
    Participant

    https://itunes.apple.com/us/app/o-quebra-nozes-cisne-negro/id1321818182?mt=8

    I used it in this application. Can you check on your iOS 11.1.2

    There are two main buttons on home screen the bottom button opens the web browser plugin. The website opens and it has code to call back from JS funcion which upon home button click/tap takes it back to home screen (two buttons screen).

    #575
    PiotrPiotr
    Keymaster

    Yeah it isn’t working for me. Again, did you check sample scene?

    #577
    mirimad
    Participant

    Yes I did. You can see the html code I gave above.

    Here is the C# code inside my app:

    public void OnMessageFromJS(string jsMessage) {
    		//InAppBrowser.OpenURL ("https://google.com?query=" + jsMessage);
    		if (jsMessage.Equals ("Go Home")) {
    			InAppBrowser.CloseBrowser ();
    			SceneManager.LoadScene ("home");
    		}
    #587
    PiotrPiotr
    Keymaster

    Does it reach code here:

    		if (jsMessage.Equals ("Go Home")) {
    			InAppBrowser.CloseBrowser ();
    			SceneManager.LoadScene ("home");
    		}

    ?

    • This reply was modified 6 years, 11 months ago by PiotrPiotr.
    #589
    mirimad
    Participant

    For some people it does and for some it don’t.

    I tried on ios 10 and it works fine. For ios 11 it does on some phones and it dont on some phones.

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