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
214 stars 26 forks source link

[IOS] app crashing on taking screenshot. #8

Closed salmanafzal775 closed 1 year ago

salmanafzal775 commented 1 year ago

I was implementing this library but when I take screenshot the app crashes.

Here is my code:

`const App = () => { useEffect(() => { SplashScreen.hide(); ScreenGuardModule.register( //insert any hex color you want here, default black if null or empty '#000000', _ => { // .....do anything you want after the screenshot }, ); }, []); return ( <QueryClientProvider contextSharing={true} client={new QueryClient()}>

</QueryClientProvider>

); };

export default App;`

Here is my react-native info:

System: OS: macOS 11.7.8 CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz Memory: 51.04 MB / 8.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 18.15.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 9.6.5 - ~/ReactProjects/smacademy/node_modules/.bin/npm Watchman: 2023.02.06.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.12.0 - /Users/salmanafzal/.rvm/gems/ruby-2.7.6/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: Not Found IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.10121639 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild Languages: Java: 17.0.1 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.6 => 0.71.6 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found

This is the version I am using: "react-native-screenguard": "^0.1.6",

I installed the library and linked it using pod install. What can be the issue?

gbumps commented 1 year ago

Please show me some react-native dependencies on your project, real device or emulator, and provide more details, like: App started at splash screen, after xx seconds I took a screenshot then app crashed, or after the app started, I switched to multitasking then took screenshot => crashed, etc...... Please provide the iOS log on your device through the MacOS app Apple Configurator for better understanding.

salmanafzal775 commented 1 year ago

Please show me some react-native dependencies on your project, real device or emulator, and provide more details, like: App started at splash screen, after xx seconds I took a screenshot then app crashed, or after the app started, I switched to multitasking then took screenshot => crashed, etc...... Please provide the iOS log on your device through the MacOS app Apple Configurator for better understanding.

Here are my dependencies: "dependencies": { "@gorhom/bottom-sheet": "^4.4.7", "@invertase/react-native-apple-authentication": "^2.2.2", "@react-native-async-storage/async-storage": "^1.18.1", "@react-native-community/art": "^1.2.0", "@react-native-community/checkbox": "^0.5.15", "@react-native-community/masked-view": "^0.1.11", "@react-native-community/netinfo": "^9.3.10", "@react-native-firebase/app": "^18.0.0", "@react-native-firebase/auth": "^18.0.0", "@react-native-google-signin/google-signin": "^10.0.1", "@react-native-picker/picker": "^2.4.10", "@react-navigation/bottom-tabs": "^6.5.7", "@react-navigation/native": "^6.1.6", "@react-navigation/stack": "^6.3.16", "axios": "^1.3.4", "deprecated-react-native-prop-types": "^4.1.0", "moment": "^2.29.4", "npm": "^9.6.5", "react": "18.2.0", "react-native": "0.71.6", "react-native-animatable": "^1.3.3", "react-native-axios": "^0.17.1", "react-native-blob-util": "^0.18.3", "react-native-cached-image": "^1.4.3", "react-native-date-picker": "^4.2.13", "react-native-fast-image": "^8.6.3", "react-native-fbsdk": "^3.0.0", "react-native-flash-message": "^0.4.1", "react-native-gesture-handler": "^2.9.0", "react-native-iap": "^12.5.0", "react-native-image-pan-zoom": "^2.1.12", "react-native-image-picker": "^5.6.0", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-linear-gradient": "^2.6.2", "react-native-media-console": "^2.0.6", "react-native-media-controls": "^2.3.0", "react-native-modal": "^13.0.1", "react-native-modalize": "^2.1.1", "react-native-modern-datepicker": "^1.0.0-beta.91", "react-native-orientation-locker": "^1.5.0", "react-native-pager-view": "^6.2.0", "react-native-paper": "^5.7.0", "react-native-pdf": "^6.6.2", "react-native-permissions": "^3.8.1", "react-native-progress": "^5.0.0", "react-native-raw-bottom-sheet": "^2.2.0", "react-native-reanimated": "^3.1.0", "react-native-reanimated-carousel": "^3.3.0", "react-native-render-html": "^6.3.4", "react-native-safe-area-context": "^4.5.0", "react-native-screenguard": "^0.1.6", "react-native-screens": "^3.20.0", "react-native-skeleton-placeholder": "^5.2.4", "react-native-slider": "^0.11.0", "react-native-snackbar": "^2.6.2", "react-native-splash-screen": "^3.3.0", "react-native-svg": "^13.9.0", "react-native-vector-icons": "^9.2.0", "react-native-video": "^5.2.1", "react-native-webview": "^12.1.0", "react-native-wheely": "^0.6.0", "react-navigation": "^4.4.4", "react-query": "^3.39.3", "yup": "^1.0.2" },

The app starts just fine like from splash to login or home screen and then when I take screenshot first the app crashes and it takes screenshot too. The screenshot color change is also working fine. I am using IOS Simulator and taking screenshot through device -> trigger screenshot.

gbumps commented 1 year ago

Apologize for the inconvenience. Can you run and build the app on Xcode, after the crashed, please capture the Xcode logs, capture at the line Terminating app due to ...... so I can clearly know why it's happened.

Have you encountered this when running on real device? I've done exactly on both real device and simulator, all works fine.

gbumps commented 1 year ago

I give you some work around to see if it still encountered

const App = () => {
        useEffect(() => {
             SplashScreen.hide();
            setTimeout(1000, () =>
             ScreenGuardModule.register(
                   //insert any hex color you want here, default black if null or empty
                  '#000000',
              _ => {
            // .....do anything you want after the screenshot 
                 },
            ));
         }, []);
return (
<QueryClientProvider contextSharing={true} client={new QueryClient()}>

);
};

export default App;

Or you can try with my example example/App.tsx to see if it's encountered.

salmanafzal775 commented 1 year ago

A

I give you some work around to see if it still encountered:

const App = () => {
        useEffect(() => {
             SplashScreen.hide();
            setTimeout(1000, () =>
             ScreenGuardModule.register(
                   //insert any hex color you want here, default black if null or empty
                  '#000000',
              _ => {
            // .....do anything you want after the screenshot 
                 },
            ));
         }, []);
return (
<QueryClientProvider contextSharing={true} client={new QueryClient()}>

);
};

export default App;

I will try this and let you know if it crashes or not and I will run it from xCode this time to capture the logs.

gbumps commented 1 year ago

Mark as done, closing. Feel free to reopen it again if it still encountered.