Skip to content
Lethe edited this page Jan 24, 2024 · 5 revisions

method


CaptureProtectionProvider

Platform: iOS v1.5.0⬆️, Android v1.5.0⬆️

Context Api Provider

recommend use top-level

Using

export default function App() {
  return (
    <CaptureProtectionProvider>
      <NavigationContainer> 
         {...}
      </NavigationContainer>
    </CaptureProtectionProvider>
  );
}

useCaptureProtection

Platform: iOS v1.5.0⬆️, Android v1.5.0⬆️

custom hook with CaptureProtectionProvider

it return isPrevent, status as var, bindProtection, releaseProtection as function

releaseProtection(rollback?:boolean) return allow all capture event

bindProtection() return prevent all capture event

Using

  const { isPrevent, status, bindProtection, releaseProtection } = useCaptureProtection();

  React.useEffect(() => {
    bindProtection();
    return () => {
      releaseProtection(true);
    };
  }, []);

 ...

addEventListener

Platform: iOS, Android v1.9.2⬆️

Using

CaptureProtection.addEventListener(({ status, isPrevent }) => {
  // do event
});

setScreenRecordScreenWithText

Platform: iOS

setting record protect screen when draw preventScreenRecord and screen is recording

Using

CaptureProtection.setScreenRecordScreenWithText("WRITE_TEXT");

setScreenRecordScreenWithImage

Platform: iOS

setting record protect screen when draw preventScreenRecord and screen is recording

Using

CaptureProtection.setScreenRecordScreenWithImage(require("image.png"));

allowScreenshot

Platform: iOS, Android v1.1.0⬆️

disable prevent screenshot event, if use true parameter, remove take screenshot event

Using

// only allow screenshot
await CaptureProtection.allowScreenshot();
// allow screenshot and remove listener
await CaptureProtection.allowScreenshot(true);

preventScreenshot

Platform: iOS, Android v1.1.0⬆️

prevent screenshot event, if user take screenshot, screenshot image will show black screen

Using

await CaptureProtection.preventScreenshot();

allowScreenRecord

Platform: iOS, Android v1.1.0⬆️

disable prevent screen recording event, if use true parameter, remove take screen recording event

Using

// only allow screen recording
await CaptureProtection.allowScreenRecord();
// allow screen recording and remove listener
await CaptureProtection.allowScreenRecord(true);

preventScreenRecord

Platform: iOS, Android v1.1.0⬆️

prevent screen recording event, if user recording screen, screen change record protect screen

when prevent recording to already record, use true parameter

Using

// prevent screen record
await CaptureProtection.preventScreenRecord();
// prevent screen record, if user already record, change immediate
await CaptureProtection.preventScreenRecord(true);

addScreenshotListener

Platform: iOS, Android v1.9.2⬆️

regist screenshot listener

Using

await CaptureProtection.addScreenshotListener();

removeScreenshotListener

Platform: iOS, Android v1.9.2⬆️

remove screenshot listener

Using

await CaptureProtection.removeScreenshotListener();

addScreenRecordListener

Platform: iOS

regist screen record listener

Using

await CaptureProtection.addScreenRecordListener();

removeScreenRecordListener

Platform: iOS

remove screen record listener

Using

await CaptureProtection.removeScreenRecordListener();

hasListener

Platform: iOS, Android v1.9.2⬆️

return listener regist status

Using

const captureListener = await CaptureProtection.hasListener();

if (captureListener?.record) {
  // record listener is exist
}
if (captureListener?.screenshot) {
  // screenshot listener is exist
}

isScreenRecording

Platform: iOS

return user recoding screen now

Using

const isScreenRecord = await CaptureProtection.isScreenRecording();

if (isScreenRecord) {
  // user already recoding
}

getPreventStatus

Platform: iOS, Android v1.1.0⬆️

return prevent event status

Using

const preventStatus = await CaptureProtection.getPreventStatus();

if (preventStatus?.record) {
  // screen record is prevent
}
if (preventStatus?.screenshot) {
  // screenshot is prevent
}