在iOS上的React Native中,有没有办法确定应用程序何时恢复?例如onResume事件



我正在尝试确定应用程序何时恢复。例如,当你打开应用程序时,按下设备上的主页按钮,然后返回应用程序。

希望您正在寻找这个。此处的文档

getInitialState: function() {
  return {
    currentAppState: AppStateIOS.currentState,
  };
},
componentDidMount: function() {
  AppStateIOS.addEventListener('change', this._handleAppStateChange);
},
componentWillUnmount: function() {
    AppStateIOS.removeEventListener('change', this._handleAppStateChange);
},
_handleAppStateChange: function(currentAppState) {
  this.setState({ currentAppState, });
},
render: function() {
  return (
     <Text>Current state is: {this.state.currentAppState}</Text>
 );
},

这是关于AppStateIOS的文档中列出的,如果这还不够,你可以使用发送事件api读取iOS文件夹中的AppDelegate.m,你可以了解更多关于iOS应用程序的生活圈。

相关内容

最新更新