Right way to handle common Apache Cordova events

I was looking through the ngCordova and have not found the equivalence for the Cordova Events plugin. From some research, they seem to be inside $ionicPlatform but I am not 100% sure how all of these events map to the way Ionic expects them to be.

Pause and Resume

For pause and resume, they should be:

$ionicPlatform.on("pause", function(){ ... });
$ionicPlatform.on("resume", function(){ ... });

Back Button

For the back button, they could be either of these 2:

  1. $ionicPlatform.onHardwareBackButton(function(){ ... }); // If using the specially provided Ionic method
  2. $ionicPlatform.on("backbutton", function(){ ... }); // If following the Cordova events plugin convention

Which is correct for Ionic Framework or both are acceptable/functionally equivalent?

Device Ready

There is this deviceready event in Cordova.

  1. $ionicPlatform.ready(function(){ ... }); // If using the specially provided Ionic method
  2. $ionicPlatform.on("deviceready", function(){ ... }); // If following the Cordova events plugin convention

Which is correct for Ionic Framework or both are acceptable/functionally equivalent?

If any Ionic expert can confirm the right method to implement them, it would be great!

1 Like