gree / gree/unity-webview

first click is ignored in iOS15

Open
#797 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
In my app, open a web page from unity and click the link in it to get that information
I receive it on the application side and open the corresponding page in a new window prepared by the application.

I'm having a problem with iOS15 and the callback when I click the link doesn't come back.
When I registered click with addEventListener on the application side, the callback came to come.
However, the first click is ignored and the second click only responds.

Are you having similar issues with iOS15?
Also, the source is as follows, but please point out any problems.

===================================================================================
html side
<a href="javascript:void(0)" onclick="Unity.call('###########')">

application side
#if !UNITY_EDITOR_WIN
m_WebViewObject.Init(
  cb: (msg) => {
    Debug.Log(string.Format("CallFromJS[{0}]", msg));
    if(callback != null) callback(msg);
  },
  err: (msg) => {
    Debug.Log(string.Format("CallOnError[{0}]", msg));
  },
  ld: (msg) => {
    Debug.Log(string.Format("CallOnLoaded[{0}]", msg));
#if !UNITY_ANDROID
    m_WebViewObject.EvaluateJS(@"
      window.addEventListener('click', function() {
        if (window && window.webkit && window.webkit.messageHandlers &&  
         window.webkit.messageHandlers.unityControl)
        {
          window.Unity = {
            call: function(msg) {
              window.webkit.messageHandlers.unityControl.postMessage(msg);
            }
          }
        } else {
          window.Unity = {
            call: function(msg) {
              window.location = 'unity:' + msg;
            }
          }
        }
      }, false);
    ");
#endif
  }
);
#endif

m_WebViewObject.SetMargins(left, top, right, bottom);

m_WebViewObject.SetVisibility(true);

m_WebViewObject.LoadURL(Url.Replace(" ", "%20"));

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 by reproducing the iOS 15 behavior with the HTML onclick handler and the application-side EvaluateJS click listener shown in the report. Compare the first and second clicks and trace whether Unity.call reaches the callback; done means identifying the cause of the missed first callback and documenting or fixing the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, javascript
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.