代码之家  ›  专栏  ›  技术社区  ›  toppsdown

ReactNative AppState在调用时多次切换状态

  •  1
  • toppsdown  · 技术社区  · 7 年前

    我正在编写一个应用程序,在这里我启动一个调用并使用 AppState:change 倾听者。我遇到了一个问题,在启动呼叫时,应用程序状态在“活动”和“非活动”之间多次切换。

    代码:

    componentDidMount() {
      AppState.addEventListener('change', this.handleAppStateChange);
    }
    
    handleAppStateChagne = (nextAppState) => {
      console.log(nextAppState);
    }
    

    在iOS上,当我启动呼叫时,使用 Linking.openURL('tel:1234567890')

    Inactive
    Active
    Inactive
    

    在Android上,日志显示:

    background
    active
    background
    

    我可以通过教我的代码期望多个更改来解决这个问题,但这不是最理想的方法。

    提前谢谢!

    0 回复  |  直到 7 年前