Open ankittripathi010 opened 2 years ago
Recent devices (especially tablets) show desktop sites by default as they can show them in sufficient high resolution. For iOS, you can forcibly show mobile sites by specifying wkContentMode to 1. For Android, there is no flag like wkContentMode but you can specify a user agent to show mobile sites. In summary, with the following change you can show mobile sites on iOS and Android devices:
diff --git a/sample/Assets/Scripts/SampleWebView.cs b/sample/Assets/Scripts/SampleWebView.cs
index 2dbe3cb..1e18291 100644
--- a/sample/Assets/Scripts/SampleWebView.cs
+++ b/sample/Assets/Scripts/SampleWebView.cs
@@ -35,6 +35,15 @@ public class SampleWebView : MonoBehaviour
{
webViewObject = (new GameObject("WebViewObject")).AddComponent<WebViewObject>();
webViewObject.Init(
+#if !UNITY_EDITOR
+#if UNITY_IOS
+ // iOS WKContentMode (0: recommended, 1: mobile, 2: desktop)
+ wkContentMode: 1,
+#elif UNITY_ANDROID
+ // Samsung Galaxy S8 user-agent
+ ua: "Mozilla/5.0 (Linux; Android 9; SM-G950N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.61 Mobile Safari/537.36",
+#endif
+#endif
cb: (msg) =>
{
Debug.Log(string.Format("CallFromJS[{0}]", msg));
When I open the url in webview on android, the webpages are opening as a desktop sites