wn-na / react-native-capture-protection

It’s a library for React Native to control simple capture events(i.e. Screenshot or Screen record)
https://www.npmjs.com/package/react-native-capture-protection
MIT License
102 stars 10 forks source link

does not support ios 12 #41

Closed HanggiAnggono closed 4 months ago

HanggiAnggono commented 5 months ago

Thanks for the great library. I checked that this lib is set with IPHONEOS_DEPLOYMENT_TARGET = 8.0; but when I try using iOS 12, the protection is not working at all. I use these functions

CaptureProtection.preventScreenshot();
CaptureProtection.preventScreenRecord();
wn-na commented 5 months ago

@HanggiAnggono hi, thx for report this. can you share react-native version?

HanggiAnggono commented 5 months ago

@HanggiAnggono hi, thx for report this. can you share react-native version?

im using version 0.66.5 as of now

wn-na commented 5 months ago

@HanggiAnggono thx. i will try iOS 12 for check for it asap

HanggiAnggono commented 5 months ago

@HanggiAnggono thx. i will try iOS 12 for check for it asap

thank you, really appreciate it

wn-na commented 5 months ago

@HanggiAnggono hello I've been testing with iOS 12 and RN 0.66 and it seems to be working fine. Can you tell me how you are using the function? Is it possible that the modal is popping up after the function is called? If use like this case, possibility it's not work, but i will fix this in the future.

HanggiAnggono commented 5 months ago

@HanggiAnggono hello I've been testing with iOS 12 and RN 0.66 and it seems to be working fine. Can you tell me how you are using the function? Is it possible that the modal is popping up after the function is called? If use like this case, possibility it's not work, but i will fix this in the future.

import { useFocusEffect } from "@react-navigation/native";
import { useCallback, useState } from "react";
import {
  CaptureProtection,
  CaptureProtectionModuleStatus,
} from "react-native-capture-protection";

export const useScreenRecordDetect = ({ enabled }: { enabled: boolean }) => {
  const [isRecording, setIsRecording] = useState(false);

  async function protectScreen() {
    CaptureProtection.preventScreenshot();
    CaptureProtection.preventScreenRecord();
    CaptureProtection.addEventListener(({ status }) => {
      if (status === CaptureProtectionModuleStatus.RECORD_DETECTED_START) {
        setIsRecording(true);
      }
    });
  }

  function releaseProtection() {
    CaptureProtection.allowScreenshot();
    CaptureProtection.allowScreenRecord();
    setIsRecording(false);
  }

  useFocusEffect(
    useCallback(() => {
      if (enabled) {
        protectScreen();
      } else {
        releaseProtection();
      }

      return () => {
        releaseProtection();
      };
    }, [enabled]),
  );

  return { isRecording };
};
useScreenRecordDetect({enabled: true});

That's how I use the library. I don't quite understand what do you mean by modal

wn-na commented 5 months ago

@HanggiAnggono hello sir

As you reported, i have confirmed that it does not work on iOS 12 or earlier. i try to fix that quickly In the meantime, we recommend using it on iOS 13 or later.

sorry that this happened to you

HanggiAnggono commented 5 months ago

@HanggiAnggono hello sir

As you reported, i have confirmed that it does not work on iOS 12 or earlier. i try to fix that quickly In the meantime, we recommend using it on iOS 13 or later.

sorry that this happened to you

thank you for the confirmation sir

wn-na commented 4 months ago

@HanggiAnggono Hi. With the new features being added, it looks like support for iOS 12 will not be possible, sorry.