Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ITS NOT WORKING ON IOS SIMULATOR ? #29

Open
kundanthe opened this issue Aug 11, 2023 · 11 comments
Open

ITS NOT WORKING ON IOS SIMULATOR ? #29

kundanthe opened this issue Aug 11, 2023 · 11 comments
Labels
invalid This doesn't seem right question Further information is requested

Comments

@kundanthe
Copy link

No description provided.

@kundanthe
Copy link
Author

its working I tested wrong way..

@yusfarhanchepa
Copy link

@kundanthe can u share how to use this library ? is it need to prevent screenshot in each screen or can make general?

is it RNScreenshotPrevent or RNPreventScreenshot ?

@kundanthe
Copy link
Author

kundanthe commented Aug 24, 2023

Hi @yusfarhanchepa
You need to use this name RNScreenshotPrevent. And its working for both.

@killserver
Copy link
Owner

this error still exist?

@killserver killserver added invalid This doesn't seem right question Further information is requested labels Oct 4, 2023
@kundanthe
Copy link
Author

HI @killserver, Its working for me.

@ajayranga
Copy link

HI getting this error in ios with latest version 1.1.9


  `(null)` is not a supported event type for RNScreenshotPrevent. Supported events are: `userDidTakeScreenshot`

  -[RCTEventEmitter addListener:]
      RCTEventEmitter.m:118
  __invoking___
  -[NSInvocation invoke]
  -[NSInvocation invokeWithTarget:]
  -[RCTModuleMethod invokeWithBridge:module:arguments:]
  facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&, int, (anonymous namespace)::SchedulingContext)
  facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const
  invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)
  _dispatch_call_block_and_release
  _dispatch_client_callout
  _dispatch_main_queue_drain
  _dispatch_main_queue_callback_4CF
  __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
  __CFRunLoopRun
  CFRunLoopRunSpecific
  GSEventRunModal
  -[UIApplication _run]
  UIApplicationMain
  main
  start_sim
  0x0
  0x0

here is source code

useEffect(() => {
    try {
      // event the trigger when user take screenshot
      if (!__DEV__) {
        RNScreenshotPrevent.enabled(true);
        RNScreenshotPrevent.enableSecureView();
      }

      if (Platform.OS === 'ios') {
        const userDidScreenshot = () => {
          console.log('Screen shot taken');
        };
        const subscription = RNScreenshotPrevent.addListener(userDidScreenshot);
        return () => {
          subscription.remove();
        };
      }
    } catch (error) {
      console.log('error', error);
    }
  }, []);

@ajayranga
Copy link

@killserver @kundanthe could you share any working code. Also we are using [email protected]

@RickRedSix
Copy link

RickRedSix commented Oct 18, 2023

@killserver @kundanthe could you share any working code. Also we are using [email protected]

Hey @ajayhcode,

I got this working by using the import stated:

import RNScreenshotPrevent, { addListener } from 'react-native-screenshot-prevent';

Then removing RNScreenshotPrevent from addListener. Here is my working code block:

  RNScreenshotPrevent.enableSecureView();
  RNScreenshotPrevent.enabled(true);

  useEffect(() => {
    
    const subscription = addListener(() => {
      Alert.alert('Warning', 'You have taken a screenshot of the app. This is prohibited due to security reasons.');    
    })
  
    return () => {
      subscription.remove();
    }
  }, [])

@ajayranga
Copy link

@RickRedSix Thanks for replying. I also got it resolved.
Can anybody explain this behavior
When we are using addListener like
addListener it works
but when we use it RNScreenshotPrevent. addListener
it is giving error

@nobi1007
Copy link

@ajayhcode the problem is addListener is not a data member of the exported RNScreenshotPrevent object. Please reference the source here.

@erie-e9
Copy link

erie-e9 commented Oct 3, 2024

is this package still working? I just tested it a few on iOS simulator but nothing happened. I tested some forks but nothing new. I need to hide content when user try to screenshot or record screen on specific screens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants