gree / gree/unity-webview

unity.call doesn't fire

Open
#225 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Objective-C++
Stars
2.7k
Forks
734
Avg merge
11h 39m
Merged PRs (30d)
1

Description

Hello, i create webview with this init:

`
newWebViewObject.Init(cb: (msg) => backfromJS(msg), transparent: false, ua: "", err: null, ld: (msg) => fullLoaded(msg), enableWKWebView: true);

void backfromJS(string msg) {
    Debug.Log(msg);
}`

i'm trying to send a message from my html to unity with this code:

<a id='a1-1-0' onclick="Unity.call('ca=1&sz=1&st=0');" class='list-group-item sub'>Test</a>

but the callback backfromJS never fires.

someone can help me.

i've see in a previous post that it can be used:
window.webkit.messageHandlers.unityControl.postMessage()

on a WKwebview, that i use, but i don't understand how.

thanks so much

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Unity WebView initialization using enableWKWebView and trace how Unity.call from the supplied HTML is bridged to cb; compare it with the mentioned window.webkit.messageHandlers.unityControl.postMessage path. Reproduce the missing backfromJS callback and verify completion when the message is logged by Debug.Log.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, javascript, unity
Domain
mobile-dev, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.