在React-Native应用程序上添加隐私视图

时间:2018-07-23 17:35:00

标签: ios react-native

我正在构建一个React-Native应用程序,出于隐私原因,当它进入任务管理器或在后台运行时,我需要隐藏应用程序屏幕的内容。

我正在使用React-Native AppState在所有未启用应用程序时会隐藏其内容的内容上显示隐私View,并删除了隐私View回到活动状态时。

它工作正常。

但是,我注意到显示Touch ID对话框时,应用程序变为inactive,它在Touch ID过程中显示了我的隐私View,这对我来说不是预期的行为。

enter image description here

小指屏幕是这里的隐私View

我试图仅在应用程序状态变为View时显示隐私background,但这已经太晚了,并且屏幕没有隐藏在任务管理器中。

这是我的组件的样子:

export default class AppPrivacy extends Component {
  state = {
    enabled: false,
  };

  componentDidMount() {
    AppState.addEventListener('change', this.handleAppStateChange);
  }

  componentWillUnmount() {
    AppState.removeEventListener('change', this.handleAppStateChange);
  }

  handleAppStateChange = (newAppState) => {
    this.setState({ enabled: newAppState !== 'active' });
  };

  render() {
    return (
      this.state.enabled && <View style={styles.container} />
    );
  }
}

我想知道只有在应用程序进入任务管理器或在后台运行时才显示隐私View的最佳方法是什么,而不是在应用程序显示“触摸ID”对话框时才显示隐私权?

仅供参考,我使用react-native-fingerprint-scanner作为Touch ID。

我还探索了软件包react-native-privacy-snapshot来创建隐私视图,但是不幸的是,它的行为与之完全相同。

谢谢!

0 个答案:

没有答案