How to use the tns-core-modules/application.on function in tns-core-modules

To help you get started, we’ve selected a few tns-core-modules examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NativeScript / NativeScript / apps / app / ui-tests-app / app.ts View on Github external
if (error.nativeError) {
        console.warn("native error: " + error.nativeError);
    }
});

application.on(application.launchEvent, function (args: application.ApplicationEventData) {
    if (args.android) {
        // For Android applications, args.android is an android.content.Intent class.
        console.log("### Launched application with: " + args.android + ".");
    } else if (args.ios !== undefined) {
        // For iOS applications, args.ios is NSDictionary (launchOptions).
        console.log("### Launched application with: " + args.ios);
    }
});

application.on(application.suspendEvent, function (args: application.ApplicationEventData) {
    if (args.android) {
        // For Android applications, args.android is an android activity class.
        console.log("#" + ++countSuspend + "# SuspendEvent Activity: " + args.android);
    } else if (args.ios) {
        // For iOS applications, args.ios is UIApplication.
        console.log("#" + ++countSuspend + "# SuspendEvent UIApplication: " + args.ios);
    }
});

application.on(application.resumeEvent, function (args: application.ApplicationEventData) {
    if (args.android) {
        // For Android applications, args.android is an android activity class.
        console.log("#" + ++countResume + "# ResumeEvent Activity: " + args.android);
    } else if (args.ios) {
        // For iOS applications, args.ios is UIApplication.
        console.log("#" + ++countResume + "# ResumeEvent UIApplication: " + args.ios);
github NativeScript / NativeScript / apps / app / ui-tests-app / app.ts View on Github external
// For iOS applications, args.ios is UIApplication.
        console.log("#" + ++countSuspend + "# SuspendEvent UIApplication: " + args.ios);
    }
});

application.on(application.resumeEvent, function (args: application.ApplicationEventData) {
    if (args.android) {
        // For Android applications, args.android is an android activity class.
        console.log("#" + ++countResume + "# ResumeEvent Activity: " + args.android);
    } else if (args.ios) {
        // For iOS applications, args.ios is UIApplication.
        console.log("#" + ++countResume + "# ResumeEvent UIApplication: " + args.ios);
    }
});

application.on(application.exitEvent, function (args: application.ApplicationEventData) {
    if (args.android) {
        // For Android applications, args.android is an android activity class.
        console.log("### ExitEvent Activity: " + args.android);
    } else if (args.ios) {
        // For iOS applications, args.ios is UIApplication.
        console.log("### ExitEvent UIApplication: " + args.ios);
    }
});

application.on(application.lowMemoryEvent, function (args: application.ApplicationEventData) {
    if (args.android) {
        // For Android applications, args.android is an android activity class.
        console.log("### LowMemoryEvent Activity: " + args.android);
    } else if (args.ios) {
        // For iOS applications, args.ios is UIApplication.
        console.log("### LowMemoryEvent UIApplication: " + args.ios);
github bitwarden / mobile / app / appMain.ts View on Github external
} else if (args.ios) {
                // For iOS applications, args.ios is UIApplication.
                console.log('UIApplication: ' + args.ios);
            }
        });

        app.on(app.displayedEvent, (args: app.ApplicationEventData) => {
            console.log('displayedEvent');
        });

        app.on(app.orientationChangedEvent, (args: app.OrientationChangedEventData) => {
            // 'portrait', 'landscape', 'unknown'
            console.log(args.newValue);
        });

        app.on(app.exitEvent, (args: app.ApplicationEventData) => {
            if (args.android) {
                // For Android applications, args.android is an android activity class.
                console.log('Activity: ' + args.android);
            } else if (args.ios) {
                // For iOS applications, args.ios is UIApplication.
                console.log('UIApplication: ' + args.ios);
            }
        });

        app.on(app.lowMemoryEvent, (args: app.ApplicationEventData) => {
            if (args.android) {
                // For Android applications, args.android is an android activity class.
                console.log('Activity: ' + args.android);
            } else if (args.ios) {
                // For iOS applications, args.ios is UIApplication.
                console.log('UIApplication: ' + args.ios);
github triniwiz / nativescript-pusher / demo-vue / app / main.ts View on Github external
import { TNSPusherBeams } from '@nativescript-pusher/beams';

TNSPusherBeams.registerForPushNotifications()
  .then(() => {
    console.log('registered');
  })
  .catch(e => {
    console.log(e);
  });
TNSPusherBeams.start('13813917-1427-42af-a2fa-cdfd31a7e1d0');

TNSPusherBeams.addOnInterestsChangeCallback(interests => {
  console.log('interests', interests);
});
application.on('launch', args => {
  TNSPusherBeams.addDeviceInterest('debug-hello');
  TNSPusherBeams.addDeviceInterest('hello');
  console.log(TNSPusherBeams.getDeviceInterests());
  TNSPusherBeams.clearDeviceInterests();
  setTimeout(() => {
    TNSPusherBeams.addDeviceInterest('debug-hello');
    TNSPusherBeams.addDeviceInterest('hello');
    TNSPusherBeams.addDeviceInterest('osei');
  }, 5000);
  // TNSPusherBeams.addOnMessageReceivedCallback(message => {
  //   console.log('message', message);
  // });
});

// Prints Vue logs when --env.production is *NOT* set while building
Vue.config.silent = TNS_ENV === 'production';
github bitwarden / mobile / app / app.ts View on Github external
// For iOS applications, args.ios is NSDictionary (launchOptions).
        console.log('Launched iOS application with options: ' + args.ios);
    }
});

app.on(app.suspendEvent, (args: app.ApplicationEventData) => {
    if (args.android) {
        // For Android applications, args.android is an android activity class.
        console.log('Activity: ' + args.android);
    } else if (args.ios) {
        // For iOS applications, args.ios is UIApplication.
        console.log('UIApplication: ' + args.ios);
    }
});

app.on(app.resumeEvent, (args: app.ApplicationEventData) => {
    if (args.android) {
        // For Android applications, args.android is an android activity class.
        console.log('Activity: ' + args.android);
    } else if (args.ios) {
        // For iOS applications, args.ios is UIApplication.
        console.log('UIApplication: ' + args.ios);
    }
});

app.on(app.displayedEvent, (args: app.ApplicationEventData) => {
    console.log('displayedEvent');
});

app.on(app.orientationChangedEvent, (args: app.OrientationChangedEventData) => {
    // 'portrait', 'landscape', 'unknown'
    console.log(args.newValue);
github NativeScript / nativescript-tooling-qa / assets / logs / hello-world-ng / main.ts View on Github external
// this import should be first in order to load some required settings (like globals and reflect-metadata)
import { platformNativeScriptDynamic } from "nativescript-angular/platform";

import { AppModule } from "./app/app.module";

import * as application from "tns-core-modules/application";
application.on(application.launchEvent, () => { 
    console.log("QA: Application started");
});
// A traditional NativeScript application starts by initializing global objects, setting up global CSS rules, creating, and navigating to the main page.
// Angular applications need to take care of their own initialization: modules, components, directives, routes, DI providers.
// A NativeScript Angular app needs to make both paradigms work together, so we provide a wrapper platform object, platformNativeScriptDynamic,
// that sets up a NativeScript application and can bootstrap the Angular framework.
platformNativeScriptDynamic().bootstrapModule(AppModule);
github NathanaelA / nativescript-orientation / src / orientation.js View on Github external
return java.lang.Class.forName("android.app.ActivityThread").getMethod("currentApplication", null).invoke(null, null);
}

function iosProperty(theClass, theProperty) {
    if (typeof theProperty === "function") {
        // xCode 7 and below
        return theProperty.call(theClass);
    } else {
        // xCode 8+
        return theProperty;
    }
}

// Setup Events
Page.on(Page.navigatingToEvent, handleNavigatingTo);
application.on(application.orientationChangedEvent, handleOrientationChange);
github EddyVerbruggen / nativescript-plugin-firebase / src / firebase.android.ts View on Github external
(() => {
  // note that this means we need to 'require()' the plugin before the app is loaded
  appModule.on(appModule.launchEvent, args => {
    if (messagingEnabled()) {
      org.nativescript.plugins.firebase.FirebasePluginLifecycleCallbacks.registerCallbacks(appModule.android.nativeApp);
    }

    const intent = args.android;
    const isLaunchIntent = "android.intent.action.VIEW" === intent.getAction();

    if (!isLaunchIntent && messagingEnabled()) {
      const extras = intent.getExtras();
      // filter out any rubbish that doesn't have a 'from' key
      if (extras !== null && extras.keySet().contains("from")) {
        let result = {
          foreground: false,
          data: {}
        };
github EddyVerbruggen / nativescript-pluginshowcase / app / utils / status-bar-util.ts View on Github external
export function setStatusBarColors() {
  // Make the iOS status bar transparent with white text
  if (application.ios) {
    application.on("launch", () => UIApplication.sharedApplication.setStatusBarStyleAnimated(UIStatusBarStyle.LightContent, true));
  }

  // Make the Android status bar transparent
  if (application.android) {
    // TODO make sure this works when --uglify'd, otherwise use "activityStarted"
    application.android.on(application.AndroidApplication.activityStartedEvent, (data: application.AndroidActivityEventData) => {
      if (application.android && device.sdkVersion >= "21") {
        let View = android.view.View;
        let window = application.android.startActivity.getWindow();
        window.setStatusBarColor(0x000000);

        let decorView = window.getDecorView();
        decorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            // | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
github EddyVerbruggen / nativescript-app-sync / demo / demoapp / main-view-model.ts View on Github external
constructor() {
    super();
    this.appSync = new AppSync();

    // Check for updates when the app is loaded or resumed
    application.on(application.resumeEvent, () => {
      this.syncWithAppSyncServer();
    });
  }