MobileBlazorBindings
MobileBlazorBindings copied to clipboard
Struggling to add webview to control existing MBB app
I'm trying to add a BlazorWebView
to the Control Gallery app so I can reproduce, and hopfully fix #286. Based on the HybridApp sample I think I've done everything right but I end up with a blank white area where my webview should be.
In the debug output in Visual Studio I get 2021-01-12 12:05:56.569325+1100 ControlGallery.iOS[42638:745934] [Process] 0x7fbeb7b67020 - [pageProxyID=6, webPageID=7, PID=42641] WebPageProxy::didFailProvisionalLoadForFrame: frameID = 3, domain = NSURLErrorDomain, code = -1002
, which I think is relevant but I can't find any meaningful solutions.
Repro of this issue is at https://github.com/lachlanwgordon/MobileBlazorBindings/tree/issues286
Any ideas?
Steps I've taken:
- Added the targets and props to iOS.csproj
- Add the index.html and wwwroot to iOS resources
- called services.AddBlazorHybrid() and builder.UseWebRoot("wwwroot") in app.cs
- called builder.UseStaticFiles in app.cs
- Add
<EnableDefaultCssItems>false</EnableDefaultCssItems>
to csproj - Added BlazorWebView tag to my view
<BlazorWebView VerticalOptions="LayoutOptions.FillAndExpand" BackgroundColor="@Color.Blue" > <ControlGallery.WebUI.App /> </BlazorWebView>
- Created WebUI/App.razor
- Added Index, MainLayout and NavMenu.razor
- setup _imports
- Copied across css from hybrid project
I've also modified the ShellNavigationManager to fix an issue with having a route "/", to stop the app crashing. I'll create a separate issue for this.
Hmm interesting, I'll have to take a closer look. Hybrid apps have quite a few additional requirements compared to non-hybrid apps so it's possible that there's some 1-line thing that's missing somewhere.