Web Analytics
Skip to main content

registerScreenguardPartially NEW ✨

Activate screenguard for a specific view region of the screen in screenshots and screen recordings, rather than the entire screen. (iOS only)

Available from v2.0.2+

v2.0.0+ Requirement

You must call initSettings() before using this function.

Parameters

Accepted a JS object with following parameters:

NameRequiredTypeDefault valueDescription
viewRefYesReact.RefObject<any>A React ref pointing to a mounted component. Its screen position and size are measured via measureInWindow().
backgroundColorNostring'#000000'(BLACK)Hex color string used to fill/mask the region in screenshots.
warning

This function only supports static screens with minimal content or size changes. It does not support components that frequently change position, or screens containing a ScrollView.

Example code

import React, { useRef } from 'react';
import { View, Text, Button } from 'react-native';
import ScreenGuardModule from 'react-native-screenguard';

const App = () => {
const sensitiveRef = useRef<View>(null);

const enablePartialGuard = async () => {
// Initialize first (required in v2.0.0+)
await ScreenGuardModule.initSettings();

// Mask only the sensitive view region
await ScreenGuardModule.registerScreenguardPartially({
viewRef: sensitiveRef,
backgroundColor: '#000000',
});
};

return (
<View>
<View ref={sensitiveRef}>
<Text>This content will be masked in screenshots</Text>
</View>
<Button title="Enable Guard" onPress={enablePartialGuard} />
</View>
);
};

Demo

iOS