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:
| Name | Required | Type | Default value | Description |
|---|---|---|---|---|
| backgroundColor | No | string | '#000000'(BLACK) | The background color you want to display |
⚠️ Removed in v2.0.0 - Use initSettings() instead |
v2.0.0 Migration: In v1.x,
timeAfterResumewas passed directly toregister(). Starting from v2.0.0, set it ininitSettings()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