android 设备上的控制台日志未按承诺触发

Console log not firing in promise on android device

我正在开发一个 Ionic 应用程序,我在其中尝试使用本机插件加载设备的联系人。有一个异步调用,里面有一些控制台日志,但是在 android 5.1 设备上 运行 时日志没有出现。 promise 中的其余代码将被触发,只有日志不会被触发。在浏览器中,它们出现了。

public loadContactsFromDevice(): void {
  console.log('ContactsProvider loadContactsFromDevice INIZIO');//this is fired
  this.contacts.find(
    ['displayName', 'name', 'birthday'],
    { filter: "", multiple: true })
    .then(resultData => {
      console.log('ContactsProvider loadContactsFromDevice resultData:' + resultData);//this is not fired
      this.allContacts = resultData;
      this.setContactsList(this.allContacts);
    });
  console.log('ContactsProvider loadContactsFromDevice FINE');//this is fired
}

我找到了解决方案。以前我调用方法来检索 app.component.ts 中的联系人 platform.ready().then(){} .. 当我把它放在 platform.ready() 之外时,日志是可见的。我不知道为什么,但它有效。