gbumps / react-native-screenguard

A Native screenshot blocking library for React-Native developer, with background customizable after captured. Screenshot detector are also supported.
https://gbumps.github.io/react-native-screenguard/
MIT License
231 stars 28 forks source link

cannot read property 'activateShield' of null #16

Closed qomi-cupist closed 1 year ago

qomi-cupist commented 1 year ago
  1. Can I just type the code together? How should I change it?
  useEffect(() => {
    if (Platform.OS === 'ios') {
      ScreenGuardModule?.register(
        //insert any hex color you want here, default black if null or empty
        '#000000',
        _ => {
          // .....do anything you want after the screenshot
        },
      );
    }
  }, []);

KakaoTalk_Photo_2023-08-30-12-47-22

  1. And if you want to perform this action when the capture button is clicked on a specific page.. Can I use the same as above? When I put it in useEffect, there was an issue where a black screen was set without capturing
gbumps commented 1 year ago
  1. have you cd ios && pod install yet ? Please double check README again to continue.
  2. the module has already been registered and run until unregisted is called. So call the function only ONCE is enough.

When I put it in useEffect, there was an issue where a black screen was set without capturing -> describe your problem more detail, iOS version running, simulator, library version you are using.

qomi-cupist commented 1 year ago

1.It works fine after cd ios && pod install, thank you🙂 , but the same issue occurs on Android. Share the device type

  1. I solved it, thank you
qomi-cupist commented 1 year ago

hmm... sorry It happens on android for both 1 and 2, can you tell me why? 🥲

gbumps commented 1 year ago

have you check this yet ?

https://github.com/gbumps/react-native-screenguard#post-installation-setting-for-android-important

if yes, open Android Studio and check the module react-native-screenguard in the Project section to see if it is linked automatically yet. (i recommend to use yarn install for autolinking).

I have checked on Android and still run normally. (I'm running v.0.2.0 (latest), Android 10, react-native 0.71.8)

qomi-cupist commented 1 year ago

I'm running v.0.2.0 (latest), Android 10, react-native 0.70.7

I think it would be good if you also update the version of react native. For example, 'RN 0.71 and higher'

Thanks for the quick reply 🙇‍♀️

meredithvf commented 10 months ago

I am getting the same error: cannot read property 'activateShield' of null. I am running with expo on ios and have followed the installation & setup including cd ios && pod install. My react version is 0.72.6.

gbumps commented 10 months ago

@meredithvf please eject expo first to continue and try latest version of react-native-screenguard v0.3.5.

antonyjo1 commented 2 months ago

The same error on Expo 51.0.26 and RN 0.74.5 IOS. On simulator everything is ok but on device shows the error.