public async override void DidFinishNavigation(WKWebView webView, WKNavigation navigation)
        {
            if (_reference == null || !_reference.TryGetTarget(out var renderer))
            {
                return;
            }
            if (renderer.Element == null)
            {
                return;
            }

            renderer.Element.HandleNavigationCompleted(webView.Url.ToString());
            await renderer.OnJavascriptInjectionRequest(HybridWebViewControl.InjectedFunction);

            if (renderer.Element.EnableGlobalCallbacks)
            {
                foreach (var function in HybridWebViewControl.GlobalRegisteredCallbacks)
                {
                    await renderer.OnJavascriptInjectionRequest(HybridWebViewControl.GenerateFunctionScript(function.Key));
                }
            }

            foreach (var function in renderer.Element.LocalRegisteredCallbacks)
            {
                await renderer.OnJavascriptInjectionRequest(HybridWebViewControl.GenerateFunctionScript(function.Key));
            }

            renderer.Element.CanGoBack    = webView.CanGoBack;
            renderer.Element.CanGoForward = webView.CanGoForward;
            renderer.Element.Navigating   = false;
            renderer.Element.HandleContentLoaded();
        }
Exemple #2
0
        public override async void OnPageFinished(Android.Webkit.WebView view, string url)
        {
            if (_reference == null || !_reference.TryGetTarget(out var renderer))
            {
                return;
            }
            if (renderer.Element == null || !renderer.Element.Navigating)
            {
                return;
            }

            renderer.Element.Navigating = false;

            renderer.Element.HandleNavigationCompleted(url);
            await renderer.OnJavascriptInjectionRequest(HybridWebViewControl.InjectedFunction);

            if (renderer.Element.EnableGlobalCallbacks)
            {
                foreach (var function in HybridWebViewControl.GlobalRegisteredCallbacks.ToList())
                {
                    await renderer.OnJavascriptInjectionRequest(HybridWebViewControl.GenerateFunctionScript(function.Key));
                }
            }

            foreach (var function in renderer.Element.LocalRegisteredCallbacks.ToList())
            {
                await renderer.OnJavascriptInjectionRequest(HybridWebViewControl.GenerateFunctionScript(function.Key));
            }

            renderer.Element.CanGoBack    = view.CanGoBack();
            renderer.Element.CanGoForward = view.CanGoForward();
            renderer.Element.HandleContentLoaded();
        }
Exemple #3
0
        private async void OnDOMContentLoaded(Windows.UI.Xaml.Controls.WebView sender, WebViewDOMContentLoadedEventArgs args)
        {
            if (Element == null)
            {
                return;
            }

            // Add Injection Function
            await Control.InvokeScriptAsync("eval", new[] { HybridWebViewControl.InjectedFunction });

            // Add Global Callbacks
            if (Element.EnableGlobalCallbacks)
            {
                foreach (var callback in HybridWebViewControl.GlobalRegisteredCallbacks)
                {
                    await Control.InvokeScriptAsync("eval", new[] { HybridWebViewControl.GenerateFunctionScript(callback.Key) });
                }
            }

            // Add Local Callbacks
            foreach (var callback in Element.LocalRegisteredCallbacks)
            {
                await Control.InvokeScriptAsync("eval", new[] { HybridWebViewControl.GenerateFunctionScript(callback.Key) });
            }

            Element.HandleContentLoaded();
        }
Exemple #4
0
        private async void OnCallbackAdded(object sender, string e)
        {
            if (Element == null || string.IsNullOrWhiteSpace(e))
            {
                return;
            }

            if ((sender == null && Element.EnableGlobalCallbacks) || sender != null)
            {
                await OnJavascriptInjectionRequestAsync(HybridWebViewControl.GenerateFunctionScript(e));
            }
        }