打开 iOS 控制中心后未执行附加到 window 事件的回调函数

callback function attached to window event not executed after opening the iOS Control Center

在我 IOS 的离子应用程序中,我正在收听由 cordova 插件生成的 window 事件。 这是我用来监听事件和执行操作的代码。

window.addEventListener('event', (event) => {
            ...
                console.log("event received");

            doSomething();
          });
doSomething(){console.log("perform an action");}

一切正常,我能够收到事件,直到我打开 IOS 控制中心(从底部向上滑动)。再次关闭控制中心后,我可以看到事件已记录 ("event received"),但函数 doSomething() 从未被调用。 有人遇到过类似情况吗?

由于事件是在 angular 之外生成的,所以我需要调用 ngZone.run 以便让 angular 知道发生了什么事情并触发更改。我是这样处理的

constructor(private zone: NgZone) {}

ngOnInit(){
        window.addEventListener('event', (event) => {

              this.ngZone.run(() => {
                do stuff;
              });
}