detect_screenshot 2.0.1
detect_screenshot: ^2.0.1 copied to clipboard
Detect screenshots and screen recording on Android and iOS, block capture with FLAG_SECURE, and hide sensitive content in the app switcher.
2.0.1 #
- updated readme
2.0.0 #
Refactors the public API to improve naming consistency. All the API functionalities stays the same
A major bump because ^1.0.0 would otherwise pull these in automatically and break existing code.
Renamed
| 1.0.2 | 2.0.0 |
|---|---|
screenshotSupport() |
checkScreenshotListenerSupport() |
screenRecordingSupport() |
checkScreenRecordListenSupport() |
appSwitcherPrivacySupport() |
checkAppSwitcherPrivacySupport() |
listenScreenshots() |
listenForScreenshots() |
listenScreenRecording() |
listenForScreenRecordings() |
1.0.2 #
- updated readme
1.0.1 #
- updated readme
1.0.0 #
Initial release.
Detection
- Screenshot detection on iOS, on Android 14+ through
Activity.ScreenCaptureCallback, and on Android 7–13 through filteredMediaStoreobservation. - Screen recording detection on iOS and Android 15+, as a stream independent of screenshots.
checkScreenshotListenerSupport()andcheckScreenRecordListenSupport()report whether a device can detect at all, so a silent stream is never ambiguous.- Every screenshot event carries the source that produced it, for segmenting analytics by tier.
MediaStoreevents are filtered on directory rather than file name, onDATE_ADDEDrecency, on row identity, and on the app being in the foreground.- On iOS, capture state is read from the scene's
sceneCaptureState. Both push mechanisms Apple offers are registered and neither is trusted: a 500ms poll backs them up while a listener is attached, emitting only on change.
Blocking and privacy
android.setScreenshotBlocked()togglesFLAG_SECURE, withandroid.isScreenshotBlocked()reading the window flag back.ios.setCaptureShield()keeps the app's pixels out of screenshots and recordings and leaves a placeholder image in their place, without changing the live screen. Built on undocumented UIKit internals; it fails open, so a future iOS that breaks it shows real content rather than breaking the app.captureShieldOverlay()renders a widget to PNG bytes for use as that placeholder.setAppSwitcherPrivacy()covers the app in the task switcher: a native overlay on iOS,setRecentsScreenshotEnabledon Android 13+.HideWhileCapturedswaps a subtree for a replacement widget while the screen is being recorded.
API
- Calls that work on both platforms sit on the detector. Platform-specific ones live under
.androidand.ios, and are harmless no-ops on the other platform, so noPlatform.isIOSguards are needed. listenForScreenshots()andlistenForScreenRecordings()return aDetectionListenerwithdispose(); the raw streams stay available for composing.