Hi everybody,
I have a little problem.
I want to make hybridapp so i added webview and custom renderer (webviewrenderer)
I want to add user agent before load start. Actually, i made it but in web page i clicked the button and route another page (for example. www.something.com/pcclient to www.something.com/pcclient/login.php) user agent header was not appear.
WebVeiwRenderer Class Code:
` partial void Load( Uri uri)
{
if (uri != null)
{
NSDictionary dictionary = NSDictionary.FromObjectsAndKeys (new NSObject[1]{NSObject.FromObject("Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25")},new NSObject[1]{NSObject.FromObject("Sub-Agent")});
NSUserDefaults.StandardUserDefaults.RegisterDefaults (dictionary);
var req=new NSMutableUrlRequest(new NSUrl(uri.AbsoluteUri));
req.Headers=dictionary;
this._webView.LoadRequest(req);
}
}
`
And i've tried this:
`private bool HandleStartLoad( UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
{
if(UIWebViewNavigationType.FormSubmitted==navigationType)
{
Load(request.Url.RelativeString);
Debug.WriteLine ("FormSubmitted Clicked");
}
return ! this.CheckRequest(request.Url.RelativeString);
}`
` protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
if ( this._webView == null)
{
this._webView = new UIWebView();
this._webView.LoadFinished += LoadFinished;
this._webView.ShouldStartLoad += this.HandleStartLoad;
this.InjectNativeFunctionScript();
this.SetNativeControl( this._webView);
var wvs = ( UrlWebViewSource)e.NewElement.Source;
this.Load( new NSUrl(wvs.Url));
}
this.Unbind(e.OldElement);
this.Bind();
}`
How can i fix this?
By the way i use Xamarin.forms.lab hybridview version="1.2.0-pre3"
Thanks for help.