Blazor.PWA.MSBuild
Blazor.PWA.MSBuild copied to clipboard
Install UI through Blazor rather than default banner?
Looking through your documentation, it sounds like I should be able to put the install button inside my app, but attempting to call await JSRuntime.InvokeAsync<object>("BlazorPWA.installPWA"); results in a WASM error: Microsoft.JSInterop.JSException: Could not find 'BlazorPWA' in 'window'.
I'm assuming I missed a step in there somewhere. I see the ServiceWorker.js and ServiceWorkerRegister.js, but nothing that contains installPWA.
Any pointers for getting the install to kick off from in Blazor, or is the banner the only option?
you will need some settings in your csproj
<PropertyGroup Label="PWA">
<ServiceWorkerRegisterInstallableType>installable-blazor</ServiceWorkerRegisterInstallableType>
<ServiceWorkerForce>true</ServiceWorkerForce>
</PropertyGroup>
ServiceWorkerRegisterInstallableType tells it you are using Blazor for the install prompt
ServiceWorkerForce just lets it update the generated files - remove it when you have it working
I found this to be a great explanation on how to creat a custom install prompt in Blazor: https://wellsb.com/csharp/aspnet/create-pwa-from-blazor-app/