Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 374
Idrees Khan Avatar asked Jun 06 '18 18:06

Idrees Khan


People also ask

What is ionic platform?

The Platform service can be used to get information about your current device. You can get all of the platforms associated with the device using the platforms method, including whether the app is being viewed from a tablet, if it's on a mobile device or browser, and the exact platform (iOS, Android, etc).


1 Answers

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.

like image 86
jcesarmobile Avatar answered Oct 05 '22 23:10

jcesarmobile