Lock / unlock screen detection in Ionic app

My question is, is there a way for the ionic application to determine if the device’s screen is locked / disabled? I know that an application can detect when it becomes “paused” and runs in the background, but that’s not what I mean. The reason for this is because I want to create a geolocation function that only works when the device screen is unlocked. Thanks

+4
source share
1 answer

you can use ionic events pause resumesee this snippet

.run(function($ionicPlatform) {
  $ionicPlatform.on("resume", function() {
    // do something update your interval
  }

  $ionicPlatform.on("pause", function() {
    // do something here to store the timestamp
  }

});
+1
source

Source: https://habr.com/ru/post/1606785/


All Articles