-
Hook Return Value Changes
- const { isPrevent, status } = useCaptureProtection(); + const { protectionStatus, status } = useCaptureProtection();
-
Method Name Changes
- CaptureProtection.preventScreenRecord(); - CaptureProtection.allowScreenRecord(); + CaptureProtection.prevent({ record: true }); + CaptureProtection.allow({ record: true }); - CaptureProtection.setScreenRecordScreenWithText("test"); + CaptureProtection.prevent({ record: { text: "test" } }); - CaptureProtection.setScreenRecordScreenWithImage(require("")); + CaptureProtection.prevent({ record: { image: require("") } }); - CaptureProtection.preventBackground(); - CaptureProtection.allowBackground(); + CaptureProtection.prevent({ appSwitcher: true }); + CaptureProtection.allow({ appSwitcher: true });
-
Unified API
- Single
prevent()andallow()methods with options - Platform-specific options for iOS and Android
- Single
-
Enhanced Event Types
- New event types for better capture event handling
- Improved event listener system
-
Improved Type Safety
- Better TypeScript support
- More precise type definitions
-
Update the package:
npm install react-native-capture-protection@latest # or yarn add react-native-capture-protection@latest -
Update your imports:
- import { - CaptureProtection, - CaptureProtectionModuleStatus, - isCapturedStatus - } from 'react-native-capture-protection'; + import { + CaptureProtection, + useCaptureProtection, + CaptureEventType + } from 'react-native-capture-protection';
-
Update your hook usage:
- const { isPrevent, status } = useCaptureProtection(); + const { protectionStatus, status } = useCaptureProtection();
-
Update your method calls:
- CaptureProtection.preventScreenRecord(); + CaptureProtection.prevent({ record: true });
-
Update your event listeners:
- CaptureProtection.addListener((event) => { - // Handle event - }); + CaptureProtection.addListener((event) => { + switch (event) { + case CaptureEventType.CAPTURED: + // Handle capture + break; + case CaptureEventType.RECORDING: + // Handle recording + break; + // ... other cases + } + });