Open incredible100rav opened 4 years ago
In your code, AddComponent()
should be AddComponent<WebViewObject>()
and you should also call webViewObject.Init()
as the sample app does. The following modification for the sample app is an example to add a custom header so could you please try:
--- a/sample/Assets/Scripts/SampleWebView.cs
+++ b/sample/Assets/Scripts/SampleWebView.cs
@@ -97,6 +97,7 @@ public class SampleWebView : MonoBehaviour
},
//ua: "custom user agent string",
enableWKWebView: true);
+ webViewObject.AddCustomHeader("auth", "abcd1234");
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
webViewObject.bitmapRefreshCycle = 1;
#endif
@@ -104,6 +105,8 @@ public class SampleWebView : MonoBehaviour
webViewObject.SetMargins(5, 100, 5, Screen.height / 4);
webViewObject.SetVisibility(true);
+ webViewObject.LoadURL("http://httpbin.org/headers");
+ yield break;
#if !UNITY_WEBPLAYER && !UNITY_WEBGL
if (Url.StartsWith("http")) {
webViewObject.LoadURL(Url.Replace(" ", "%20"));
I'm trying to set a custom header for the webview, but it's not working. Custom headers are not set. This is a sample of my code.
StartCoroutine(WebLoad("https://testapp.xyz.com")); IEnumerator WebLoad(string Url) { webViewObject = (new GameObject("WebViewObject")).AddComponent();
webViewObject.AddCustomHeader("auth", PlayerPrefs.GetString("token"));
webViewObject.LoadURL(Url.Replace(" ", "%20"));
}