FabriBertani / Plugin.Maui.ScreenSecurity

Safeguard your .NET MAUI app effortlessly by preventing content exposure, screenshots, and recordings with ease.
MIT License
160 stars 12 forks source link

protection not working if declared ScreenSecurity.Default.ActivateScreenSecurityProtection() globally, working only with MainPage.xaml.cs file #30

Closed chandu15x closed 6 months ago

chandu15x commented 7 months ago

I want to restrict screen sharing, screen recording & screenshot capturing from all the pages of my .NET MAUI application. I tried to use Plugin.Maui.ScreenSecurity.

I observed it's working if we add it MainPage.xaml.cs file. I tried to apply it globally as below.

In App.xaml.cs file

 public App()
 {
     InitializeComponent();
     ScreenSecurity.Default.ActivateScreenSecurityProtection();
     MainPage = new AppShell();
 }

Also tried in CreateMauiApp() in MauiProgram.cs file as below

 var app = builder.Build();
 ScreenSecurity.Default.ActivateScreenSecurityProtection();
 return app;

None seems to be working if applied globally as above. Is this a bug or any other way to apply it globally at one place?

chandu15x commented 7 months ago

@FabriBertani pls take a look

FabriBertani commented 6 months ago

Hi @chandu15x, hope you're doing well.

I've check this and the main problem is that you're trying to initialize the plugin too soon, please try with the latest version (currently 1.1.8-beta) and do it inside the OnAppearing method of the first page of your app. Please check the sample project to check how is done.