question

JyothiV-4979 avatar image
0 Votes"
JyothiV-4979 asked ColeXia-MSFT answered

Disable ScreenShot in iOS using Xamarin Forms

Hi, I have tried to disable the Screenshot capture in iOS project. Did not get any reference to disable directly. I have used the below code but not able to add the blur screen at the time of screencapture. Is there any other way to disable the screenshot in iOS 14 and above.


public override void OnResignActivation(UIApplication uiApplication)
{
base.OnResignActivation(uiApplication);

// Prevent taking snapshot
uiApplication.IgnoreSnapshotOnNextApplicationLaunch();


var bgView = new UIView(uiApplication.KeyWindow.Frame) { Tag = 42, Alpha = 0, BackgroundColor = Color.FromHex("#449CD5").ToUIColor() };

uiApplication.KeyWindow.AddSubview(bgView);
uiApplication.KeyWindow.BringSubviewToFront(bgView);


UIView.Animate(0.5, () =>
{
bgView.Alpha = 1;
});
}

public override void OnActivated(UIApplication uiApplication)
{
base.OnActivated(uiApplication);

var view = uiApplication.KeyWindow.ViewWithTag(42);


if (view != null)
{
UIView.Animate(0.5, () =>
{
view.Alpha = 0;
}, () =>
{
view.RemoveFromSuperview();
});
}
}

regards,
Jyothi.

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ColeXia-MSFT avatar image
0 Votes"
ColeXia-MSFT answered

Hello,

Welcome to Microsoft Q&A!

It seems that this could be achieved before iOS 7, see this solution .

However from iOS 7 there is no way to prevent user to take screen shot .

We can only get notified after screen shot is taken , not before or while , see this comment .


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.