public WebHybridSamplePage()
        {
            this.BackgroundColor = Color.White;
            var stack = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand };
            hwv = new HybridWebView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand };

            stack.Children.Add(hwv);
            this.Content = stack;

            hwv.RegisterCallback("dataCallback", t =>
                Device.BeginInvokeOnMainThread(() =>
                {
                    this.DisplayAlert("Data callback", t, "OK");
                })
            );

            //hwv.RegisterNativeFunction("funcCallback", s => new object[] {"Func return data for " + s});

            hwv.RegisterCallback("sendObject", s =>
            {
                var serializer = Resolver.Resolve<IJsonSerializer>();

                var o = serializer.Deserialize<SendObject>(s);

                System.Diagnostics.Debug.WriteLine(o.X);
                System.Diagnostics.Debug.WriteLine(o.Y);
            });
        }
Exemplo n.º 2
0
 public HighScoresPageViewModel(INavigation navigation, HybridWebView webView)
     : base(navigation)
 {
     HasHtmlPageSignalled = false;
     WebView    = webView;
     SourceHtml = "highScores.html";
 }
Exemplo n.º 3
0
        public WebHybridSamplePage()
        {
            this.BackgroundColor = Color.White;
            var stack = new StackLayout {
                VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            hwv = new HybridWebView {
                VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            stack.Children.Add(hwv);
            this.Content = stack;

            hwv.RegisterCallback("dataCallback", t =>
                                 Device.BeginInvokeOnMainThread(() =>
            {
                this.DisplayAlert("Data callback", t, "OK");
            })
                                 );

            //hwv.RegisterNativeFunction("funcCallback", s => new object[] {"Func return data for " + s});

            hwv.RegisterCallback("sendObject", s =>
            {
                var serializer = Resolver.Resolve <IJsonSerializer>();

                var o = serializer.Deserialize <SendObject>(s);

                System.Diagnostics.Debug.WriteLine(o.X);
                System.Diagnostics.Debug.WriteLine(o.Y);
            });
        }
        public WebHybridTestPage()
        {
            var stack = new StackLayout {
                VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
            };
            var hwv = new HybridWebView {
                VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            stack.Children.Add(hwv);
            this.Content = stack;

            hwv.Uri = new Uri("http://test.padrose.co.uk/hvw/test1.html");

            hwv.RegisterCallback("dataCallback", t =>
                                 Device.BeginInvokeOnMainThread(() =>
            {
                /**********************************/
                //THIS WILL WORK FOR PAGE 1 ONLY
                /*********************************/
                System.Diagnostics.Debug.WriteLine("!!!!!!!!!!!!!!!!! dataCallback: " + t);
            })
                                 );

            hwv.LoadFinished += (s, e) =>
            {
                /***********************************/
                //THIS WILL WORK FOR PAGE 1 ONLY
                //WEAK REFERENCE LOST???
                /***********************************/
                System.Diagnostics.Debug.WriteLine("(!!!!!!!!!!!!!!!!!!!! LoadFinished");
            };
        }
 public JSBridge(HybridWebViewRenderer hybridRenderer)
 {
     hybridWebViewRenderer = new WeakReference <HybridWebViewRenderer>(hybridRenderer);
     HybridWebView hybridWebView = new HybridWebView();
     bool          value         = hybridWebViewRenderer.TryGetTarget(out HybridWebViewRenderer hybrid);
     string        uri           = hybrid.Element.Uri;
 }
        public WebHybridSamplePage()
        {
            this.Content = this.hybrid = new HybridWebView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.White
            };

            this.hybrid.RegisterCallback("dataCallback", t =>
                Device.BeginInvokeOnMainThread(() =>
                {
                    this.DisplayAlert("Data callback", t, "OK");
                })
            );

            this.hybrid.RegisterCallback("sendObject", s =>
            {
                var serializer = Resolver.Resolve<IJsonSerializer>();

                var o = serializer.Deserialize<SendObject>(s);

                this.DisplayAlert("Object", string.Format("JavaScript sent x: {0}, y: {1}", o.X, o.Y), "OK");
            });

            this.hybrid.RegisterNativeFunction("funcCallback", t => new object[] { "From Func callback: " + t });
        }
Exemplo n.º 7
0
        void PageDataLoaded()
        {
            if (_hybridWebView == null)
            {
                _hybridWebView = new HybridWebView(new JsonNetJsonSerializer());
                _hybridWebView.HorizontalOptions = LayoutOptions.FillAndExpand;
                _hybridWebView.VerticalOptions   = LayoutOptions.FillAndExpand;
                _hybridWebView.RegisterCallback("EditVisible", (data) => {
                    PageModel.EditVisible.Execute(data);
                });
                _hybridWebView.RegisterNativeFunction("GetGraphData", (input) => {
                    return(PageModel.GetGraphData(input));
                });

                _hybridWebView.LoadFinished += (s, e) => {
                    string data = JsonConvert.SerializeObject(PageModel.GraphData).Replace("\r\n", "");
                    _hybridWebView.InjectJavaScript("JellyBeanTrackerApp.buildChartStr('" + data + "');");
                };
                Content = _hybridWebView;
            }

            var profitReportRazorView = new JellyBeanGraph(); // { Model = PageModel.GraphData };
            var html = profitReportRazorView.GenerateString();

            _hybridWebView.LoadContent(html.Replace("\r\n", ""));
        }
Exemplo n.º 8
0
        public WebHybridSamplePage()
        {
            this.BackgroundColor = Color.White;
            var stack = new StackLayout {
                VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            hwv = new HybridWebView {
                VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            stack.Children.Add(hwv);
            this.Content = stack;

            hwv.Uri = new Uri("http://test.padrose.co.uk/hvw/test1.html");

            hwv.RegisterCallback("dataCallback", t =>
                                 Device.BeginInvokeOnMainThread(() =>
            {
                this.DisplayAlert("Data callback", t, "OK");
            })
                                 );

            hwv.RegisterNativeFunction("funcCallback", s => new object[] { "Func return data for " + s });
        }
        public WebHybridSamplePage()
        {
            this.Content = this.hybrid = new HybridWebView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                BackgroundColor   = Color.White
            };

            this.hybrid.RegisterCallback("dataCallback", t =>
                                         Device.BeginInvokeOnMainThread(() =>
            {
                this.DisplayAlert("Data callback", t, "OK");
            })
                                         );

            this.hybrid.RegisterCallback("sendObject", s =>
            {
                var serializer = Resolver.Resolve <IJsonSerializer>();

                var o = serializer.Deserialize <SendObject>(s);

                this.DisplayAlert("Object", string.Format("JavaScript sent x: {0}, y: {1}", o.X, o.Y), "OK");
            });

            this.hybrid.RegisterNativeFunction("funcCallback", t => new object[] { "From Func callback: " + t });
        }
Exemplo n.º 10
0
        public LoginView()
        {
            //_formTemplates = formTemplates;
            var stack = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                BackgroundColor   = Color.Azure
            };

            _hybrid = new HybridWebView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                BackgroundColor   = Color.Azure
            };

            RegisterCallBacks();
            stack.Children.Add(_hybrid);
            Content = new ScrollView
            {
                HorizontalOptions = LayoutOptions.Fill,
                Orientation       = ScrollOrientation.Horizontal,
                Content           = stack
            };
            LoadSource();
            //_hybrid.LoadFinished += (s, e) => { LoadHtml(); };
            BackgroundColor = Color.FromHex("#3C444D");
            //NavigationPage.SetHasBackButton(this, false);
            //NavigationPage.SetHasNavigationBar(this, false);
            //Icon = FontAwesome.;
            Padding = new Thickness(0, -1000, 0, 200);
        }
Exemplo n.º 11
0
 public BridgeManager(HybridWebView hybrid, LoungingPage loungingPage)
 {
     bridge     = hybrid;
     page       = loungingPage;
     serializer = Resolver.Resolve <IJsonSerializer>();
     SetUpCallBacks();
 }
Exemplo n.º 12
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.WebView> e)
        {
            base.OnElementChanged(e);
            _xwebView = e.NewElement as HybridWebView;
            _webView  = Control;

            Control.SetWebViewClient(new HybridWebViewClient(_xwebView));
        }
Exemplo n.º 13
0
        public TermsOfServicePage()
        {
            InitializeComponent();


            header = new Label
            {
                Text              = "WebView Javascript Test",
                FontSize          = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                HorizontalOptions = LayoutOptions.Center
            };


            var serializer = new XLabs.Serialization.JsonNET.JsonSerializer();

            webView = new HybridWebView(serializer)
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                IsVisible         = true
            };


            var button1 = new Button {
                Text = "Call JavaScript Directly"
            };

            button1.Clicked += OnCallJavaScriptButton1Clicked;

            var button2 = new Button {
                Text = "Call JavaScript using EtherifyService"
            };

            button2.Clicked += OnCallJavaScriptButton2Clicked;


            // Accomodate iPhone status bar.
            var padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);


            //TODO: Crashing in the android simulator because of https://code.google.com/p/android/issues/detail?id=189040

            this.Padding = padding;
            this.Content = new StackLayout
            {
                BackgroundColor = Color.Red,
                Children        =
                {
                    header,

                    button1,
                    button2,
                    webView
                }
            };
        }
Exemplo n.º 14
0
 public LoungingPage()
 {
     InitializeComponent();
     this.Content = this.hybrid = new HybridWebView
     {
         HorizontalOptions = LayoutOptions.FillAndExpand,
         VerticalOptions   = LayoutOptions.FillAndExpand,
         BackgroundColor   = Color.Blue
     };
 }
Exemplo n.º 15
0
        public EtherifyServiceProviderJsImpl(HybridWebView hybridWebView)
        {
            if (hybridWebView == null)
            {
                throw new ArgumentNullException("hybridWebView");
            }

            _hybridWebView = hybridWebView;

            RegisterCallbacksForJavascriptCalls();
        }
Exemplo n.º 16
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="url">The url to use. When a notification is received on Android, this is set to the notification url</param>
        public MainPage(string url = "")
        {
            // create a new hybrid webview
            _webview = new HybridWebView(new JsonSerializer())
            {
                Uri = ResolveUrl(url),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            // resume event
            SubscribeToResume();

            // push notification handler
            NotificationReceived += (sender, args) => {
                var notificationArgs = args as NotificationEventArgs;
                _webview.Uri = notificationArgs.NotificationUrl;
            };

            // register callbacks
            RegisterCallbacks();

            // handle load finished
            _webview.LoadFinished += (sender, args) => {
                _webview.InjectJavaScript(ScriptHelper.ScriptChecker);
            };

            // handle webview errors
            _webview.LoadError += async(sender, args) => {
                var select = await DisplayAlert("Connection error", $"The {Constants.DisplayShortName} site could not be loaded", $"Select another {Constants.DisplayShortName} site", "Retry");

                if (select)
                {
                    CrossSettings.Current.Remove("userguid");
                    CrossSettings.Current.Remove("url");
                    CrossSettings.Current.Remove("theme");

                    SelectSite();
                }
                else
                {
                    _webview.Uri = ResolveUrl(url);
                }
            };

            // the layout
            if (Device.RuntimePlatform == Device.iOS)
            {
                Padding = new Thickness(0, 50);
            }

            Content = _webview;
        }
Exemplo n.º 17
0
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                userController.RemoveAllUserScripts();
                userController.RemoveScriptMessageHandler("invokeAction");
                HybridWebView hybridWebView = e.OldElement as HybridWebView;
                hybridWebView.Cleanup();
            }
        }
Exemplo n.º 18
0
        public App()
        {
            var webView = new HybridWebView();

            MainPage = new ContentPage {
                Content = webView
            };
            webView.Navigated += delegate {
                webView.RunScriptAsync(KitchenSink.CallJavaScript);
            };
            webView.Source = new BundleWebViewSource("www/index.html");
        }
Exemplo n.º 19
0
        public async Task BaseSetup()
        {
            WebView = NativeWebView = new HybridWebView(Activity);
            NativeWebView.Settings.JavaScriptEnabled = true;

            var client = new LoadingTaskClient();

            NativeWebView.SetWebViewClient(client);
            NativeWebView.LoadUrl("about:blank");

            await client.Loaded;

            await Setup();
        }
Exemplo n.º 20
0
        public WebPageLoadSample()
        {
            this.pages = new List <Uri>(new[]
            {
                new Uri("http://www.openstreetmap.org "),
                new Uri("https://www.google.pl/maps"),
                new Uri("https://www.bing.com/maps/ "),
            });

            this.Padding = new Thickness(0, 20, 0, 0);

            this.hybrid = new HybridWebView()
            {
                BackgroundColor   = Color.Red,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                StyleId           = "HybridWebView",
            };


            var mainLayout = new RelativeLayout
            {
                StyleId = "MainLayout",
            };

            this.addressLabel = new Label()
            {
                StyleId  = "UrlLoaded",
                FontSize = 8
            };

            var labelHeight = Device.OnPlatform(10, 10, 20);

            mainLayout.Children.Add(this.addressLabel,
                                    Constraint.Constant(0),
                                    Constraint.Constant(0),
                                    Constraint.RelativeToParent(p => p.Width),
                                    Constraint.Constant(labelHeight));

            mainLayout.Children.Add(this.hybrid,
                                    Constraint.Constant(0),
                                    Constraint.RelativeToView(addressLabel, (p, v) => v.Y + v.Height),
                                    Constraint.RelativeToParent(p =>
            {
                return(p.Width);
            }),
                                    Constraint.RelativeToView(addressLabel, (p, v) => p.Height - v.Height));

            this.Content = mainLayout;
        }
Exemplo n.º 21
0
        // 초기화 코드
        public void Init()
        {
            token = GetToken("0355094063652427", "X99IhH4l6FSbElhjFVUSl7DJKWw7AKGxTQfbykxE0pPFK7Zq3Ujo1W8MTEUtoA0iqguYB1DBrthcAgCD");
            NavigationPage.SetHasNavigationBar(this, false); // Navigation Bar 지우는 코드 생성자에 입력 token = GetToken("0355094063652427", "X99IhH4l6FSbElhjFVUSl7DJKWw7AKGxTQfbykxE0pPFK7Zq3Ujo1W8MTEUtoA0iqguYB1DBrthcAgCD");
            var webViewXaml = new HybridWebView
            {
                Uri = "file:///android_asset/IMP.html",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Param             = param,
            };

            Content = webViewXaml;

            webViewXaml.RegisterAction(CallbackFunc);
        }
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                userController.RemoveAllUserScripts();
                userController.RemoveScriptMessageHandler("invokeAction");
                HybridWebView hybridWebView = e.OldElement as HybridWebView;
                hybridWebView.Cleanup();
            }

            if (e.NewElement != null)
            {
                string filename = Path.Combine(NSBundle.MainBundle.BundlePath, $"Content/{((HybridWebView)Element).Uri}");
                LoadRequest(new NSUrlRequest(new NSUrl(filename, false)));
            }
        }
Exemplo n.º 23
0
        void PageDataLoaded()
        {
            if (_hybridWebView == null)
            {
                _hybridWebView = new HybridWebView(new SystemJsonSerializer());
                _hybridWebView.HorizontalOptions = LayoutOptions.FillAndExpand;
                _hybridWebView.VerticalOptions   = LayoutOptions.FillAndExpand;

                Content = _hybridWebView;
            }

            var profitReportRazorView = new ProfitReport()
            {
                Model = PageModel.ProfitData
            };
            var html = profitReportRazorView.GenerateString();

            _hybridWebView.LoadContent(html.Replace("\r\n", ""));
        }
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                _userController.RemoveAllUserScripts();
                _userController.RemoveScriptMessageHandler("invokeAction");
                HybridWebView hybridWebViewMain = e.OldElement as HybridWebView;
                hybridWebViewMain?.Cleanup();
            }

            if (e.NewElement != null)
            {
                //// No need this since we're loading dynamically generated HTML content
                //string filename = Path.Combine(NSBundle.MainBundle.BundlePath, $"Content/{((HybridWebView)Element).Uri}");
                //LoadRequest(new NSUrlRequest(new NSUrl(filename, false)));
            }
        }
Exemplo n.º 25
0
        public WebHybridSamplePage()
        {
            this.BackgroundColor = Color.White;
            var stack = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand };
            hwv = new HybridWebView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand };

            stack.Children.Add(hwv);
            this.Content = stack;

            hwv.Uri = new Uri("http://test.padrose.co.uk/hvw/test1.html");

            hwv.RegisterCallback("dataCallback", t =>
                Device.BeginInvokeOnMainThread(() =>
                {
                    this.DisplayAlert("Data callback", t, "OK");
                })
            );

            hwv.RegisterNativeFunction("funcCallback", s => new object[] {"Func return data for " + s});
        }
 public WordSearchPageViewModel(INavigation navigation, int secondsRemaining, int pointsPerLetter, HybridWebView webViewHeader, HybridWebView webViewTiles)
     : base(navigation)
 {
     IsLoading              = true;
     HasTilesPageSignalled  = false;
     HasHeaderPageSignalled = false;
     WebViewHeader          = webViewHeader;
     WebViewTiles           = webViewTiles;
     StartingSeconds        = secondsRemaining;
     SecondsRemaining       = secondsRemaining;
     PointsPerLetter        = pointsPerLetter;
     Debug.Assert(SecondsRemaining > 0);
     Debug.Assert(PointsPerLetter > 0);
     GameScore     = 0;
     GameCompleted = false;
     ScoreBoard    = $"Puntos: {GameScore}";
     WordSearchHeaderSourceHtml = "wordSearchHeader.html";
     WordSearchTilesSourceHtml  = "wordSearchTiles.html";
     StartGameTimer();
 }
Exemplo n.º 27
0
        public HybridPage()
        {
            var jsonSerializer = Resolver.Resolve <IJsonSerializer>();

            this.hybrid = new HybridWebView(jsonSerializer)
            {
                BackgroundColor = Color.Blue
            };

            var buttonHeight = Device.OnPlatform(100, 100, 100);

            var layout = new RelativeLayout();

            layout.Children.Add(this.hybrid,
                                Constraint.Constant(0),
                                Constraint.Constant(20),
                                Constraint.RelativeToParent(p => p.Width),
                                Constraint.RelativeToParent(p => p.Height - buttonHeight));

            this.Content = layout;
        }
Exemplo n.º 28
0
        public XamarinFormsWebViewSamplePage()
        {
            InitializeComponent();

            var serializer = new JsonSerializer();
            var webView    = new HybridWebView(serializer)
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Margin          = new Thickness(20, 30),
                Uri             = new Uri(WebViewUrl)
            };

            webView.RegisterCallback(LoginCallback, (arg) =>
            {
                var loginForm = serializer.Deserialize <LoginFormDto>(arg);
                var result    = loginForm.Username == Username;
                webView.CallJsFunction(DisplayLoginAlertFunctioName, new[] { result.ToString() });
            });

            Content = webView;
        }
Exemplo n.º 29
0
        public async Task Logout(string token)
        {
            var client = new HttpClient();
            //some servers could not support
            var result = await client.GetAsync(GetRevokeUri(_settingsProvider, token));

            if (!result.IsSuccessStatusCode)
            {
                return;
            }

            if (_adalPage != null)
            {
                _adalPage.HybridWebView.ClearCookies(null);
            }
            else
            {
                var hybridWebView = new HybridWebView();
                hybridWebView.ClearCookies(null);
            }
        }
        // I'm so insanely mad that I need to even do this…. The problem is that the Android
        // renderer for the HybridWebView does not marshal back to the UI thread when the
        // native function is complete at that causes Android to fail on Lollipop+. Since building
        // my own version of HybridWebView is insanely hard and subclassing the existing one is
        // impossible, we have our *2 version of this method which works the same way but puts
        // the callback onto the right flippin thread!
        public static void RegisterNativeFunction_Custom(this HybridWebView hybridWebView, string name, Func <string, object[]> func)
        {
            hybridWebView.RegisterCallback(name, (s) =>
            {
                // Get the appended callback ID
                var index      = s.LastIndexOf('!');
                var callbackId = s.Substring(index + 1);
                s = s.Substring(0, index);

                Task.Run(() =>
                {
                    // Run the native function
                    var args = func(s);

                    // The magic that was missing from the original...
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        hybridWebView.CallJsFunction("nativeFuncs2[" + callbackId + "]", args);
                    });
                });
            });
        }
Exemplo n.º 31
0
        public BaiduMapView(SearchSuggestModel searchSuggestModel)
        {
            InitializeComponent();

            _searchSuggestModel = searchSuggestModel;

            //todo:使用xaml构建该页面
            _absoluteLayout = new AbsoluteLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            _hybirdWeb = new HybridWebView
            {
                Uri = "index.html",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            _absoluteLayout.Children.Add(_hybirdWeb, new Rectangle(0, 0, DeviceInfo.Width, DeviceInfo.Height));

            _searchEntry = new Entry
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor   = Color.White,
                Placeholder       = "搜索"
            };
            //_searchEntry.Focused += SearchEntryOnFocused;

            _absoluteLayout.Children.Add(_searchEntry,
                                         new Rectangle(20, 35, DeviceInfo.Width - 40, AbsoluteLayout.AutoSize));

            Content = _absoluteLayout;

            //Messenger.Default.Register<SearchSuggestModel>(this, MessengeToken.SearchCallBack, SearchKeyWordCallBack);
            //_hybirdWeb.InvokeJsFunction("loadJScript", null, _searchSuggestModel.Lng, _searchSuggestModel.Lat);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <WebView> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement != null)
            {
                Control.RemoveJavascriptInterface("jsBridge");
            }
            if (e.NewElement != null)
            {
                webView = e.NewElement as HybridWebView;

                Control.AddJavascriptInterface(new JSBridge(this), "jsBridge");
                InjectJS(JavaScriptFunction);
            }

            void InjectJS(string script)
            {
                if (Control != null)
                {
                    Control.LoadUrl(string.Format("javascript: {0}", script));
                }
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());

            String lang = Java.Util.Locale.Default.ToString().IndexOf("ru") >= 0 ? "ru" : "en";

            App app = Xamarin.Forms.Application.Current as App;

            MainPage mainPage = app.MainPage as MainPage;

            HybridWebView webView = mainPage.InitWebView();

            jivoSdk = new JivoSdk(webView, lang)
            {
                JivoDelegate = this
            };
            jivoSdk.Prepare();
        }