Welcome! › Forums › Unity Plugins › In-App Web Browser › Where is webkit.messageHandlers.UnityInAppBrowser?
Tagged: InAppBrowser, javascript
- This topic has 11 replies, 2 voices, and was last updated 3 years, 9 months ago by nategametaco.
-
AuthorPosts
-
December 15, 2020 at 10:45 pm #11643nategametacoParticipant
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?
December 16, 2020 at 10:15 am #11644PiotrKeymasterI don’t understand your question. What do you mean by “where is the JS”?
December 16, 2020 at 4:05 pm #11646nategametacoParticipantWhere 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.
December 16, 2020 at 7:59 pm #11648PiotrKeymasterIts not JS library but something injected by Apple APIs. You dont have to worry about including anything.
December 24, 2020 at 4:31 am #11666nategametacoParticipantWe 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.
December 24, 2020 at 3:44 pm #11670PiotrKeymasterHey, this part looks good. Maybe you can try example JS communication scene – is it working for you?
December 29, 2020 at 3:58 am #11673nategametacoParticipantIt 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.
December 29, 2020 at 2:56 pm #11675PiotrKeymasterHey,
There is nothing more than in example.
OpenExampleJavaScriptCommunicationScene
, click onBrowserOpener
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.January 5, 2021 at 6:14 pm #11679nategametacoParticipantGot 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!
January 11, 2021 at 2:59 am #11687nategametacoParticipantBump.
January 11, 2021 at 1:03 pm #11688PiotrKeymasterOnly way I think it could be possible is with JS + some DOM manipulation, there is no any API for that.
January 12, 2021 at 1:56 am #11689nategametacoParticipantWith 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
-
AuthorPosts
- You must be logged in to reply to this topic.