What is the all-platform equivalent of Cordova's `deviceReady` event?

What is the Capacitor equivalent of Cordova’s deviceReady event? I’m trying to find the appropriate place to initialize the inapp purchase public in Ionic React.

Angular has this.platform.ready(), but what does Capacitor provide?

@Hills90210 I’m asking about React and Capacitor in general; I’m not sure how linking to the Angular docs is helpful. With Capacitor, Angular platform has a ready method but React and Vue don’t, so what’s the right way to implement Cordova’s deviceReady() in a platform-agnostic with Capacitor?

Interesting Question! To use Capacitor Plugins, you don’t need to wait for a Device Ready Event. If you’re using Cordova Plugins in your Capacitor App, it could be possible that you need to wait for the Device, but I’m not quite sure. Do you face any issues by not using the Device Ready Event? @ptmkenny

You should have stated it was in reference to react in your first post, i would have posted a different answer.

cordova-plugin-purchase specifically needs to be initialized when the device is ready..

This needs to be done or all calls to the store will fail and the app will crash. So I’m looking for the equivalent in Capacitor. It seems that Angular has such an event, but there’s nothing for React or Vue.

The vanilla javascript way should work

document.addEventListener("deviceready", function(){
//do something when device is ready
}, false);
1 Like