Web Analytics
Skip to main content

getScreenGuardLogs NEW ✨

Version

Available from v2.0.0+

Retrieve ScreenGuard activity logs for debugging and monitoring purposes.

Parameters

NameRequiredTypeDefaultDescription
maxCountNonumber10Maximum number of log entries to retrieve. Range: 1 - 1,000,000

Return Type

Returns Promise<Array<ScreenGuardLogEntry> | null>

ScreenGuardLogEntry

interface ScreenGuardLogEntry {
timestamp: number;
action: string;
isProtected: boolean;
method: string;
}
FieldTypeDescription
timestampnumberUnix timestamp (milliseconds) when the log was recorded
actionstringThe action that was performed. Possible values: 'activate', 'deactivate', 'screenshot_detected', 'recording_started', 'recording_stopped'
isProtectedbooleanWhether the screen was protected at the time of this log entry
methodstringThe effect method used. Possible values: 'blur', 'image', 'color', 'none', '' (empty if not activated)

Example code

import ScreenGuardModule from 'react-native-screenguard';

// Initialize with tracking enabled
await ScreenGuardModule.initSettings({
trackingLog: true,
});

// ... after some screenguard operations ...

// Get last 20 log entries
const logs = await ScreenGuardModule.getScreenGuardLogs(20);

if (logs) {
logs.forEach((log) => {
console.log(`[${new Date(log.timestamp).toISOString()}] ${log.action} - Protected: ${log.isProtected}`);
});
}
Important
  • Requires trackingLog: true in initSettings() to properly collect logs.
  • If trackingLog is false, a warning will be shown and logs may be empty.
  • Must call initSettings() before using this function.