react-native-private-screen
v0.2.0
Published
React Native screen privacy for Android, including capture protection and Samsung Knox Privacy Display readiness.
Maintainers
Readme
react-native-private-screen
Screen privacy for React Native on Android: block capture, mark sensitive content, and prepare Samsung Knox Privacy Display policies for managed Galaxy S26 Ultra devices.
What it supports
FLAG_SECUREscreenshot and non-secure display protection- Best-effort Android content sensitivity
- Galaxy S26 Ultra and Knox Service Plugin readiness detection
- Typed Samsung Privacy Display deployment plans for UEM administrators
Samsung Privacy Display is not a normal app API. Samsung exposes it through Knox Service Plugin 26.05 as an enterprise OEMConfig policy. An app cannot toggle the hardware feature directly; a UEM administrator must deploy the policy.
Install
npm install react-native-private-screenRebuild the Android app after installation. iOS is intentionally unsupported; protection calls are no-ops and support detection returns unavailable.
Protect sensitive screens
import { useEffect } from 'react';
import { PrivateScreen } from 'react-native-private-screen';
export function SensitiveScreen() {
useEffect(() => {
void PrivateScreen.setScreenCaptureProtection('flagSecure');
void PrivateScreen.setContentSensitivity('sensitive');
return () => {
void PrivateScreen.setScreenCaptureProtection('off');
void PrivateScreen.setContentSensitivity('notSensitive');
};
}, []);
return null;
}FLAG_SECURE blocks screenshots, screen recording, and presentation on non-secure displays at the window level. Android content sensitivity is best-effort and silently does nothing on unsupported OS builds.
Prepare Samsung Privacy Display
First, inspect whether the current device is eligible and obtain the host application's package name:
import { PrivateScreen } from 'react-native-private-screen';
const support = await PrivateScreen.getSamsungPrivacyDisplaySupport();
console.log(support.availability);
console.log(support.appPackageName);
console.log(support.device?.kspVersionName);Then generate the values an administrator should map into the Knox Service Plugin managed configuration:
import {
createSamsungPrivacyDisplayDeploymentPlan,
} from 'react-native-private-screen';
const plan = createSamsungPrivacyDisplayDeploymentPlan({
scope: 'deviceWide',
target: 'selectedApps',
packageNames: ['com.example.securebanking'],
enableCredentialEntry: true,
allowUserToChangePrivacyDisplay: false,
allowUserToChangeApps: false,
allowUserToChangeCredentialEntry: false,
});
console.log(plan.policyPath);
console.log(plan.values);The generated object is a typed deployment guide, not a raw Android Management API payload. KSP's managed-configuration keys are supplied dynamically to compatible UEM consoles, so the administrator should map the returned values in the KSP configuration UI.
Samsung requirements
- Galaxy S26 Ultra (
SM-S948*) - Android 16 and One UI 8.5
- Knox 3.13 or newer
- First One UI 8.5 maintenance release or newer
- Knox Service Plugin 26.05 (
1.5.64) or newer, deployed through a compatible UEM
getSamsungPrivacyDisplaySupport() can verify the manufacturer, model, Android API level, and installed KSP version. It cannot prove that the required One UI maintenance release, Knox version, license, enrollment, or policy assignment is active.
API
PrivateScreen.setScreenCaptureProtection(mode)
Modes: 'off', 'flagSecure', and 'flagSecureOnDemand'. The two secure modes currently apply the same Android window flag; flagSecureOnDemand is retained for API compatibility.
PrivateScreen.setContentSensitivity(mode)
Modes: 'notSensitive', 'sensitive', and 'auto'.
PrivateScreen.getSamsungPrivacyDisplaySupport()
Returns device eligibility, KSP installation/version information, the host package name, documented requirements, and canToggleFromApp: false.
PrivateScreen.openSamsungPrivacyDisplaySettings()
Opens the closest documented Android settings screen available. Samsung does not publish a dedicated Privacy Display intent.
createSamsungPrivacyDisplayDeploymentPlan(options)
Validates package names and returns a device-wide or work-profile KSP configuration guide for all screens or selected applications.
Official Samsung documentation
- Knox Service Plugin 26.05 release notes
- Advanced Restriction policies
- Knox Service Plugin managed configurations
License
MIT
