In the App Programming Guide for iOS, Apple says:
When an app transitions to the background, the system takes a snapshot of the app’s main window, which it then presents briefly when transitioning your app back to the foreground. Before returning from your
applicationDidEnterBackground:
method, you should hide or obscure passwords and other sensitive personal information that might be captured as part of the snapshot.
This react-native module obscure passwords and other sensitive personal information when an app transitions to the background.
- Run
npm install react-native-privacy-snapshot --save
in your project directory - Run
(cd ios && pod install)
to trigger react-native autolinking
import { usePrivacySnapshot} from 'react-native-privacy-snapshot';
...
usePrivacySnapshot()
The following functions are exported:
Hook to apply the privacy snapshot when app goes to background. This will apply as long as this component is mounted
import { usePrivacySnapshot } from "react-native-privacy-snapshot";
const MyComponent = () => {
usePrivacySnapshot();
return <View>...</View>;
};
Enable the privacy screen to trigger when app goes to background.
import { enabled } from "react-native-privacy-snapshot";
enabled(true);
//Later...
enabled(false);
Show the privacy screen right now
import { show } from "react-native-privacy-snapshot";
show();
Hide the privacy screen right now
import { show, hide } from "react-native-privacy-snapshot";
show();
//Later
hide();