nhn / gpm.unity

A brand of NHN providing free services required for game development.

Home Page:https://gameplatform.nhncloud.com/en/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WebView로 window.open()사용시 customScheme에 대한 문의

rws08 opened this issue · comments

commented

Service

  • WebView
  • AssetManagement
  • Communicator
  • LogViewer
  • Manager
  • UI
  • Profiler
  • Adapter
  • DLST

Version

1.12.1

Summary

WebView에서 Javascript function으로 window.open()에 customScheme을 전달하는 경우 GpmWebViewCallback.CallbackType.Scheme 으로 값이 안오는데 제가 잘못 사용하는 건가요?

Screenshots

If applicable, add screenshots to help explain your question.

Additional context

Add any other context about the problem here.

안녕하세요. @rws08님.
GPM을 사용해 주셔서 감사합니다.

먼저 아래 단계로 테스트 했을 때 별다른 이슈가 없었습니다.

  • GpmWebView.ShowHtmlString을 이용해 웹페이지 활성화
  • 버튼 액션을 통해 window.open(customScheme://url) 호출
  • Unity에서 GpmWebViewCallback.CallbackType.Scheme 호출 확인

조금 더 정확한 확인을 위해 아래 내용에 대해 확인 부탁드립니다.

  • Unity Editor 버전
  • Device target SDK 버전
  • Javascript를 호출하는 step 정보 및 제공 가능한 코드

감사합니다.

commented

@taehyeon-nhn 아래와 같이 테스트 했습니다.

  • Unity Editor 버전 : 2019.4.0
  • Device target SDK 버전 : iOS 17.0
  • 코드
GpmWebView.ShowHtmlString(
            @"
            <!DOCTYPE html>
<html>
  <body>
    <a href='customscheme://close'>close</a>

    <button
      class='favorite styled'
      type='button'
      onclick='test();'
    >
      Test
    </button>
  </body>
  <script>
    function test() {
            window.open('customscheme://close')
          }
  </script>
</html>
", ...

@rws08 님. 혹시 custom scheme을 등록했는지 확인 부탁드립니다.
이 경우 아래와 같이 호출되어야 custom scheme callback이 호출됩니다.
GpmWebView.ShowHtmlString(htmlString, Configuration, OnWebViewCallback, new List<string> { "customscheme://" }));

commented

@taehyeon-nhn 님. 빠른 답변 감사합니다.
'<a href' 를 통해서는 custom scheme callback 이 호출되는건 확인했습니다. window.open 인 경우만 호출이 안되는 상태입니다.
혹시 몰라서 사용한 코드 전체 추가합니다.

  • window.open 시도시 로그
    • iOS17에서는 아래 로그도 출력이 안됩니다.
2023-07-13 16:19:02.393456+0900 KlipSDKUnity[1972:140438] -canOpenURL: failed for URL: "customscheme://asyncTestResponse" - error: "This app is not allowed to query for scheme customscheme"
  • '<a href' 시도시 로그
2023-07-13 16:19:04.164309+0900 KlipSDKUnity[1972:140438] 🐞[GPM][WebView][iOS][GPMWebViewController.m:(909)] Try to open URL (iOS 13) : customscheme://close
OnAsyncEvent : {"callbackType":9,"data":"customscheme:\/\/close","scheme":"gpmwebview:\/\/webViewCallback","callback":0}
  • 사용 코드
GpmWebView.ShowHtmlString(
            @"
            <!DOCTYPE html>
<html>
  <body>
    <a href='customscheme://close'>close</a>

    <button
      class='favorite styled'
      type='button'
      onclick='test();'
    >
      Test
    </button>
  </body>
  <script>
    function test() {
            window.open('customscheme://close')
          }
  </script>
</html>
",
new GpmWebViewRequest.Configuration()
            {
                style = GpmWebViewStyle.POPUP,
                // orientation = GpmOrientation.LANDSCAPE,
                isClearCookie = true,
                isClearCache = true,
                backgroundColor = "#FFFFFF",
                isNavigationBarVisible = true,
                navigationBarColor = "#4B96E6",
                title = "The page title.",
                isBackButtonVisible = true,
                isForwardButtonVisible = true,
                supportMultipleWindows = false,
    #if UNITY_IOS
                contentMode = GpmWebViewContentMode.MOBILE,
    #endif
            },
            OnCallback,
            new List<string>()
            {
                "customscheme://"
            });

@rws08 님. 코드 공유 감사합니다.
확인 후 내용 전달드리겠습니다.

@rws08님 안녕하세요.

아래 링크를 참고하여 테스트 부탁드립니다.
https://stackoverflow.com/questions/11816380/window-open-does-not-work-on-ios-app-using-phone-gap
window.open => window.location.href

추가로 아래 링크의 내용을 테스트해보았으나 답변의 내용으로 정상 동작하지 않았습니다.
https://developer.apple.com/forums/thread/664267

감사합니다.

@rws08님 안녕하세요.
이슈 종료하겠습니다.

추가 문의 사항이 있으시면 언제든 편하게 문의 부탁드립니다.
감사합니다.