gree / gree/unity-webview

WebViewObject hooked callback not beeing called

Open
#1,186 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

Hi,

I have a problem that the "hooked" or "cb" callbacks defined in the Init method of the WebViewObject never seem to be called. ld and start seem to work fine and are printed in the logs. I require some code to execute when a redirect happens though (change destination url). Below is my code for displaying the WebView. I compile for android currently. I hope somebody can give me a pointer how to solve this.

void OpenWebView(string url)
  {
      webView = new GameObject("WebViewObject").AddComponent<WebViewObject>();
      webView.Init(
          cb: (msg) => {
              Debug.Log("WebView callback: " + msg);
              if (msg.StartsWith(redirectUri))
              {
                  msg = msg.Replace("http://localhost:8080", proxyUrl);
                  HandleRedirect(msg);
              }
          },
          err: (msg) => Debug.LogError("WebView error: " + msg),
          httpErr: (msg) => Debug.Log("WebView HTTP Error" + msg),
          started: (msg) => Debug.Log("WebView started: " + msg),
          ld: (msg) => Debug.Log("WebView loaded: " + msg),
          hooked: (msg) => Debug.Log("WebView hooked: " + msg),
          enableWKWebView: true
      );

    
      webView.SetMargins(0, 0, 0, 0);
      webView.SetVisibility(true);
     
      string hookPattern = "^" + Regex.Escape("http://localhost:8080");
      webView.SetURLPattern(".*", "", hookPattern);
      webView.LoadURL(url);
  }

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 at the WebViewObject.Init, SetURLPattern, and LoadURL calls shown in the issue, then trace how Android handles the hooked and cb callbacks. Verify the URL pattern and redirect path against the callback wiring; done means the expected callback logs and handles a matching redirect.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, csharp, unity
Domain
mobile-dev, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.