Skip to content

WebViewObject hooked callback not beeing called #1186

@Alex-Dee

Description

@Alex-Dee

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);
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions