Closed steindin closed 1 year ago
Hi @steindin
I don't know what or how you're trying, but this plugin does work with Blazor.
Considering that Blazor is embedded within the Maui app via BlazorWebView
and the lifecycle relies on Maui, you can use this plugin as described in the docs or sample within the Maui app context (page code behind or ViewModel).
Remember to register the plugin on the MauiProgram.cs
:
builder.Services.AddSingleton<IScreenSecurity>(ScreenSecurity.Default);
Or use the default instance directly:
ScreenSecurity.Default.EnableScreenSecurityProtection();
Also, you can execute the methods on Blazor:
@page "/"
@using Plugin.Maui.ScreenSecurity;
@inject IScreenSecurity ScreenSecurity
<h1>Hello, world!</h1>
Welcome to your new app.
<SurveyPrompt Title="How is Blazor working for you?" />
<button class="btn btn-primary" @onclick="EnableScreenSecurity">Enable Screen Security</button>
<button class="btn btn-secondary" @onclick="DisableScreenSecurity">Disable Screen Security</button>
@code
{
void EnableScreenSecurity()
{
#if ANDROID
ScreenSecurity.EnableScreenSecurityProtection();
#elif IOS
ScreenSecurity.EnableBlurScreenProtection(Plugin.Maui.ScreenSecurity.Platforms.iOS.ThemeStyle.Light);
#endif
}
void DisableScreenSecurity()
{
#if ANDROID
ScreenSecurity.DisableScreenSecurityProtection();
#elif IOS
ScreenSecurity.DisableBlurScreenProtection();
#endif
}
}
Hope this clarifies your question.
Closed due to not being an issue/bug.
Hi! I have tried implementing this plugin in my .net MAUI Blazor App, but it doesnt seem to work! Is this plugin enabled for Blazor, or not?