Search code examples
angularcordovaionic-frameworkionic4capacitor

Why platform ready event doesn't fire in Capacitor?


I have just installed Capacitor and it seems there is no need to add platform ready event. I have tried this code:

  async initializeApp() {
    await Browser.open({
      url: 'https://www.google.com'
    });
    this.platform.ready().then(() => {
      console.log('ready');
    });
  }

Whatever i add inside ready event, it doesnt fire (like cordova). And it seems i am able to call the native apis directly without ready event. However, if we use cordova plugins, where we are supposed to call them ?
Edit: there seems to be an issue in V4.Alpha7 as described here.


Solution

  • As you said, this was an Ionic 4 bug and it's fixed now.

    About when to call Cordova plugins, same way as Capacitor plugins, you can call them as soon as the app launches without waiting for ready event.

    But once the fix is releases you can also keep the ready code if you want. It will work the same way as ready will also be called as soon as your app launches.