@wuilmerj24/screen-protector
v1.0.3
Published
A NativeScript plugin to enhance app security by preventing screenshots and screen recordings. Includes real-time detection of capture events on iOS and automatically applies screen protection on both Android and iOS. Ideal for protecting sensitive conten
Maintainers
Readme
@wuilmerj24/screen-protector
A NativeScript plugin to protect sensitive content from screen capture and recording.
This plugin provides API methods to block screenshots and detect screen recording events — with native support for both iOS and Android.
📦 Installation
npm install @wuilmerj24/screen-protector📱 Platform Support
| Feature | Android | iOS | |---------------------------|:-------:|:-------:| | Block Screenshots | ✅ | ✅ | | Block Screen Recording | ✅ | ✅ | | Detect Screenshots | ❌ | ✅ | | Detect Screen Recording | ❌ | ✅ |
🚀 Usage
Import the plugin
import { ScreenProtector } from '@wuilmerj24/screen-protector';Initialize and use
const protector = new ScreenProtector();
// Block screenshots
protector.lockScreenShoots();
// Optionally set up listeners (iOS only)
protector.setScreenshootEvent(() => {
console.log('📸 Screenshot detected (iOS)');
});
protector.setScreenRecorderEvent((isRecording: boolean) => {
console.log('📹 Screen recording changed:', isRecording);
});To remove protection
protector.unlockScreenShoots();
// Remove observers (iOS only)
protector.removeScreenShootObserver();
protector.removeScreenRecorderObserver();🧪 API
lockScreenShoots(): boolean
Blocks screenshots and screen recordings:
- On iOS, it uses a secure UITextField to force the system to blur the screen.
- On Android, it sets
FLAG_SECUREto prevent all screen capture mechanisms.
unlockScreenShoots(): boolean
Restores the normal behavior, allowing screenshots again.
setScreenshootEvent(callback: () => void): void
iOS only
Registers a listener that fires when the user takes a screenshot.
setScreenRecorderEvent(callback: (isRecording: boolean) => void): void
iOS only
Registers a listener that tracks whether screen recording is active (true or false).
removeScreenShootObserver(): void
iOS only
Removes the screenshot observer.
removeScreenRecorderObserver(): void
iOS only
Removes the screen recording observer.
📝 License
Apache License Version 2.0
👨💻 Author
Maintained by @wuilmerj24
License
Apache License Version 2.0
