diff --git a/src/BlazorMobile.Web/Components/BlazorMobileComponent.cs b/src/BlazorMobile.Web/Components/BlazorMobileComponent.cs index 198b72b..afc165a 100644 --- a/src/BlazorMobile.Web/Components/BlazorMobileComponent.cs +++ b/src/BlazorMobile.Web/Components/BlazorMobileComponent.cs @@ -103,6 +103,12 @@ internal bool IsWebAssembly() return _isWebAssembly; } + private async Task SetRemoteDebugEndpoint() + { + string uri = BlazorMobileService.GetContextBridgeURI(); + await Runtime.InvokeVoidAsync("BlazorXamarin.SetDebugRemoteEndpoint", uri); + } + private async Task JSRuntimeHasElectronFeature() { return await Runtime.InvokeAsync("BlazorXamarin.JSRuntimeHasElectronFeature"); @@ -193,6 +199,9 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { _FirstInit = false; + //Adding remote endpoint for debugging + await SetRemoteDebugEndpoint(); + JSRuntime = Runtime; SetCurrentRuntime(JSRuntime); diff --git a/src/BlazorMobile.Web/wwwroot/blazormobile.js b/src/BlazorMobile.Web/wwwroot/blazormobile.js index 93c3b09..4c04abb 100644 --- a/src/BlazorMobile.Web/wwwroot/blazormobile.js +++ b/src/BlazorMobile.Web/wwwroot/blazormobile.js @@ -27,6 +27,12 @@ window.BlazorXamarin = { selectedElement.style.display = "none"; } } + }, + + SetDebugRemoteEndpoint: function (endpoint) { + if (endpoint !== undefined && endpoint !== null) { + window.contextBridge.connectivity._contextBridgeURI = endpoint; + } } };