Skip to content

Latest commit

 

History

History
105 lines (80 loc) · 2.49 KB

File metadata and controls

105 lines (80 loc) · 2.49 KB

Migration Guide

From v1.x to v2.x

Breaking Changes

  1. Hook Return Value Changes

    - const { isPrevent, status } = useCaptureProtection();
    + const { protectionStatus, status } = useCaptureProtection();
  2. 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 });

New Features

  1. Unified API

    • Single prevent() and allow() methods with options
    • Platform-specific options for iOS and Android
  2. Enhanced Event Types

    • New event types for better capture event handling
    • Improved event listener system
  3. Improved Type Safety

    • Better TypeScript support
    • More precise type definitions

Migration Steps

  1. Update the package:

    npm install react-native-capture-protection@latest
    # or
    yarn add react-native-capture-protection@latest
  2. Update your imports:

    - import {
    -   CaptureProtection,
    -   CaptureProtectionModuleStatus,
    -   isCapturedStatus
    - } from 'react-native-capture-protection';
    + import {
    +   CaptureProtection,
    +   useCaptureProtection,
    +   CaptureEventType
    + } from 'react-native-capture-protection';
  3. Update your hook usage:

    - const { isPrevent, status } = useCaptureProtection();
    + const { protectionStatus, status } = useCaptureProtection();
  4. Update your method calls:

    - CaptureProtection.preventScreenRecord();
    + CaptureProtection.prevent({ record: true });
  5. 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
    +   }
    + });