首页 > 解决方案 > 如何检测 React Native 中的抽屉通知?

问题描述

我尝试将来自 react-native 的 AppState 与模糊侦听器一起使用,但没有显示任何内容。我做了完全相同的代码https://reactnative.dev/docs/appstate但模糊侦听器不起作用。我只想知道通知抽屉(https://developer.android.com/guide/topics/ui/notifiers/notifications#bar-and-drawer)何时出现在我的应用程序屏幕上

  export default class AppStateExample extends Component {
  state = {
    appState: AppState.currentState
  };

  componentDidMount() {
    AppState.addEventListener("blur", this._handleAppStateChange);
  }

  componentWillUnmount() {
    AppState.removeEventListener("blur", this._handleAppStateChange);
  }

  _handleAppStateChange = nextAppState => {
   console.log("test")
  };
}

感谢帮助 !

标签: react-native

解决方案


推荐阅读