如果应用程序已打开,如何捕获? (本地脚本)

how to capture if an application has been opened? (NativeScript)

我想在打开应用程序时捕获事件。

Ex: Waze 应用程序已打开,从这一刻起我想捕获一个事件并决定应用程序是否可以 继续它 运行

是的,你可以在 Ionic 中做,你可以在 ionic 中看到 .运行 函数打开。

app.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

      // Don't remove this line unless you know what you are doing. It stops the viewport
      // from snapping when text inputs are focused. Ionic handles this internally for
      // a much nicer keyboard experience.
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }


       // write your function for capturing an event and make it use where ever you need.

  });
})

.运行 将在应用程序打开时自动 运行 并设置该应用程序所需的所有内容,因此请尝试将您的内容放入其中,以便您轻松完成任务