private void ShowHtml(string htmlContent, MapPoint position)
        {
            // Create the web view
            WebKit.WKWebView myWebView = new WebKit.WKWebView(new CGRect(), new WebKit.WKWebViewConfiguration());

            // Load the HTML content
            myWebView.LoadHtmlString(new NSString(htmlContent), new NSUrl(""));

            // Show the callout
            _myMapView.ShowCalloutAt(position, new WebViewWrapper(myWebView));
        }
Beispiel #2
0
            static void UserAgentFromWKWebView()
            {
                WebKit.WKWebViewConfiguration wkconf = new WebKit.WKWebViewConfiguration()
                {
                };
                WebKit.WKWebView wkwv = new WebKit.WKWebView(CoreGraphics.CGRect.Empty, wkconf);

                // TODO: WKWebKit UserAgent JavaScript handler not triggered from JavaScript
                WebKit.WKJavascriptEvaluationResult handler =
                    (NSObject result, NSError err) =>
                {
                    app_name_wkwebview  = null;
                    useragent_wkwebview = null;

                    if (err != null)
                    {
                        System.Console.WriteLine(err);
                    }
                    if (result != null)
                    {
                                #if DEBUG
                        System.Diagnostics.Debug.WriteLine($"User-Agent API result");
                                #endif
                    }

                    return;
                };

                // case sensitive stuff:
                //      navigator.*
                // few SO posts with Pascal case will not work!
                wkwv.EvaluateJavaScript((NSString)"navigator.appName", handler);
                wkwv.EvaluateJavaScript((NSString)"navigator.userAgent", handler);

                wkwv.LoadHtmlString("<html></html>", null);

                #if DEBUG
                System.Diagnostics.Debug.WriteLine($"User-Agent API useragent_wkwebview = {useragent_wkwebview}");
                #endif

                return;
            }