Does anyone knows how to set custom user agent for a WebView both on Android and iOS. Unfortunately, I have not found a working solution.
I will be very glad for any help.
If you need that functionality, you will need to use a DependencyService or CustomRenderer as outlined in these guides:
Custom renderer: http://developer.xamarin.com/guides/cross-platform/xamarin-forms/custom-renderer/
For more details, you can check the following link:
I have checked this link earlier. Unfortunately, it does not work for me and also there is no solution for Android.
In order to help you better, could you please post a basic demo or code snippet you tried so that we can help you better?
Ok. So let's take iOS for example. Setting a custom user should not be hard because WKWebView has CustomUserAgent property.https://docs.microsoft.com/en-us/dotnet/api/webkit.wkwebview.customuseragent?view=xamarin-ios-sdk-12
Here is my example code for a renderer on iOS:
[assembly: ExportRenderer(typeof(WebView), typeof(CustomWebViewRenderer))]
public class CustomWebViewRenderer : ViewRenderer<WebView, WKWebView>
protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
if (e.NewElement != null && Control != null)
Control.CustomUserAgent = "core_together_mobile_ios";
However this is not working because now "Navigating" and "Navigated" events are not triggered.
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies