Web Analytics
Skip to main content

register

Activate the screenguard with your custom background color layout.

v2.0.0+ Requirement

You must call initSettings() before using this function.

Parameters

Accepted a JS object with following parameters:

NameRequiredTypeDefault valueDescription
backgroundColorNostring'#000000'(BLACK)The background color you want to display
timeAfterResumeNonumber1000⚠️ Removed in v2.0.0 - Use initSettings() instead

v2.0.0 Migration: In v1.x, timeAfterResume was passed directly to register(). Starting from v2.0.0, set it in initSettings() instead.

Example code

import ScreenGuardModule from 'react-native-screenguard';

// Initialize first (required in v2.0.0+)
await ScreenGuardModule.initSettings({
displayScreenGuardOverlay: true,
timeAfterResume: 2000,
});

// Then activate ScrenGuard
await ScreenGuardModule.register({
backgroundColor: '#0F9D58',
});
Android Note

On Android, if displayScreenguardOverlayAndroid is set to false in initSettings(), calling register() will automatically switch to registerWithoutEffect() and show a warning.

Demo

iOS

Android