gree / unity-webview

zlib License
2.22k stars 684 forks source link

help webview no reaction. #263

Open ohchangmin opened 6 years ago

ohchangmin commented 6 years ago

hi, I'm writing a webview that you can use. However, I have a problem with writing and I am writing to ask about this. error use with kakao

There is no problem with Chrome. ;;; If kakao is installed, you will be provided with the relevant information ... It will not work on the webview you provide. Is there any way ??


https://developers.kakao.com/docs/js/demos/custom-login

KojiNakamaru commented 6 years ago

The button opens another window by window.open, which isn't currently supported. It might work if you redefine window.open to perform a page transition in the ld: callback as below.

diff --git a/sample/Assets/Scripts/SampleWebView.cs b/sample/Assets/Scripts/SampleWebView.cs
index 9ec7973..c86da56 100644
--- a/sample/Assets/Scripts/SampleWebView.cs
+++ b/sample/Assets/Scripts/SampleWebView.cs
@@ -72,6 +72,14 @@ public class SampleWebView : MonoBehaviour
                 ");
 #endif
 #endif
+                webViewObject.EvaluateJS(@"
+                  window.open = function(open) {
+                    return function(url, name, features) {
+                      window.location.href = url;
+                      return window;
+                    };
+                  }(window.open);
+                ");
                 webViewObject.EvaluateJS(@"Unity.call('ua=' + navigator.userAgent)");
             },
             //ua: "custom user agent string",

cf. https://stackoverflow.com/questions/10909190/detect-window-open-from-uiwebview/11106153#11106153