How to use application - 10 common examples

To help you get started, we’ve selected a few application 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 alg / nativescript-fcm / index.ios.js View on Github external
function init() {
  var nc    = Utils.ios.getter(NSNotificationCenter, NSNotificationCenter.defaultCenter);
  var queue = Utils.ios.getter(NSOperationQueue, NSOperationQueue.mainQueue);

  // Subscribe to token refreshes
  nc.addObserverForNameObjectQueueUsingBlock("kFIRInstanceIDTokenRefreshNotification", null, queue, _onTokenRefresh);
  nc.addObserverForNameObjectQueueUsingBlock("didRegisterUserNotificationSettings", null, queue, _onPermissionRequestResult);

  // Signup to events
  Application.on(Application.resumeEvent, _connectToFCM);
  Application.on(Application.suspendEvent, _disconnectFromFCM);

  // Configure the application
  FIRApp.configure();
}
github hypery2k / nativescript-fabric / src / fabric.ios.ts View on Github external
init(): void {
    if (application.ios) {
      application.ios.delegate = FabricAppDelegate;
      this.initDone = true;
    }
    application.on('uncaughtError', args => {
      if (application.ios) {
        // For iOS applications, args.ios is NativeScriptError.
        this.logError(args);
      }
    });
  }
github hypery2k / nativescript-fabric / src / fabric.android.ts View on Github external
application.android.on('activityStarted', activityEventData => {
          console.info('Fabric: Activating Fabric kits');
          // Enable Fabric crash reporting
          io.fabric.sdk.android.Fabric.with(new io.fabric.sdk.android.Fabric.Builder(activityEventData.activity)
            .kits([
              // init Fabric with plugins
              new com.crashlytics.android.Crashlytics(),
              new com.crashlytics.android.answers.Answers()
            ])
            .debuggable(false)
            .build()
          );
          this.initDone = true;
          console.info('Fabric: Init done');
        });
        application.on('uncaughtError', args => {
          if (!args.android) {
            let msg = args.toString();
            try {
              msg = stringify(args);
            } catch (ignored) {

            }
            com.crashlytics.android.Crashlytics.getInstance().core.log(android.util.Log.ERROR, 'ERROR', msg);
          } else {
            com.crashlytics.android.Crashlytics.getInstance().core.logException(this.getErrorDetails(args));
          }
        });
      }
    } catch (e) {
      console.error('Unknown error during init of Fabric', e);
    }
github argonjs / argon-app / app / main-page.js View on Github external
// Set the icon for the menu button
    var menuButton = exports.page.getViewById("menuButton");
    menuButton.text = String.fromCharCode(0xe5d4);
    // Set the icon for the overview button
    var overviewButton = exports.page.getViewById("overviewButton");
    overviewButton.text = String.fromCharCode(0xe53b);
    // workaround (see https://github.com/NativeScript/NativeScript/issues/659)
    if (exports.page.ios) {
        setTimeout(function () {
            exports.page.requestLayout();
        }, 0);
        application.ios.addNotificationObserver(UIApplicationDidBecomeActiveNotification, function () {
            exports.page.requestLayout();
        });
    }
    application.on(application.orientationChangedEvent, function () {
        setTimeout(function () {
            checkActionBar();
            updateSystemUI();
        }, 500);
    });
    AppViewModel_1.appViewModel.ready.then(function () {
        AppViewModel_1.appViewModel.argon.session.errorEvent.addEventListener(function (error) {
            // alert(error.message + '\n' + error.stack);
            if (error.stack)
                console.log(error.message + '\n' + error.stack);
        });
        AppViewModel_1.appViewModel.showBookmarks();
    });
    if (application.android) {
        var activity = application.android.foregroundActivity;
        activity.onBackPressed = function () {
github EddyVerbruggen / nativescript-plugin-firebase / firebase.ios.js View on Github external
firebase._processPendingNotifications = function () {
  var app = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
  if (!app) {
    application.on("launch", function () {
      firebase._processPendingNotifications();
    });
    return;
  }
  if (firebase._receivedNotificationCallback !== null) {
    for (var p in firebase._pendingNotifications) {
      var userInfoJSON = firebase._pendingNotifications[p];
      // move the most relevant properties (if set) so it's according to the TS definition and aligned with Android
      if (userInfoJSON.aps && userInfoJSON.aps.alert) {
        userInfoJSON.title = userInfoJSON.aps.alert.title;
        userInfoJSON.body = userInfoJSON.aps.alert.body;
      }
      // also, to make the ts.d happy copy all properties to a data element
      userInfoJSON.data = userInfoJSON;
      // cleanup
      userInfoJSON.aps = undefined;
github tralves / groceries-ns-vue / app / utils / statusBar.js View on Github external
export function setStatusBarColors() {
  // Make the iOS status bar transparent with white text.
  if (application.ios) {
    application.on("launch", () => {
      utils.ios.getter(UIApplication, UIApplication.sharedApplication).statusBarStyle = UIStatusBarStyle.LightContent;
    });
  }

  // Make the Android status bar transparent.
  // See http://bradmartin.net/2016/03/10/fullscreen-and-navigation-bar-color-in-a-nativescript-android-app/
  // for details on the technique used.
  if (application.android && platform.device.sdkVersion >= "21") {
    application.android.on("activityStarted", () => {
      const View = android.view.View;
      const window = application.android.startActivity.getWindow();
      window.setStatusBarColor(0x000000);

      const decorView = window.getDecorView();
      decorView.setSystemUiVisibility(
        View.SYSTEM_UI_FLAG_LAYOUT_STABLE
github jlooper / angular-starter / nativescript / src / mobile / core / services / ns-app.service.ts View on Github external
ActionBarUtil.STATUSBAR_STYLE(
      isIOS ? 1 : '#3280CF'
    );

    if (String('<%= BUILD_TYPE %>') !== 'prod') {
      log.debug('NSAppCmp ----');

      router.events.subscribe((e) => {
        this.log.debug(`Router Event: ${e.toString()}`);
      });
    }

    // Fix: Reset all nsApp events before subscribing to avoid Duplicate events.
    // this.unsubscribeAll();

    nsApp.on(nsApp.launchEvent, (eventData: nsApp.LaunchEventData) => {
      this.log.info('TNS Application - Launched!');
    });

    nsApp.on(nsApp.suspendEvent, (eventData: nsApp.ApplicationEventData) => {
      this.log.info('TNS Application - Suspended');
    });

    nsApp.on(nsApp.resumeEvent, (eventData: nsApp.ApplicationEventData) => {
      this.log.info('TNS Application - Resumed');
    });

    nsApp.on(nsApp.lowMemoryEvent, (eventData: nsApp.ApplicationEventData) => {
      this.log.warn('TNS Application - !!! LOW MEMORY !!!');
    });

    nsApp.on(nsApp.exitEvent, (eventData: any) => {
github jlooper / angular-starter / nativescript / app / mobile / core / services / ns-app.service.ts View on Github external
ActionBarUtil.STATUSBAR_STYLE(
      isIOS ? 1 : '#3280CF'
    );

    if (String('<%= BUILD_TYPE %>') !== 'prod') {
      log.debug('NSAppCmp ----');

      router.events.subscribe((e) => {
        this.log.debug(`Router Event: ${e.toString()}`);
      });
    }

    // Fix: Reset all nsApp events before subscribing to avoid Duplicate events.
    // this.unsubscribeAll();

    nsApp.on(nsApp.launchEvent, (eventData: nsApp.LaunchEventData) => {
      this.log.info('TNS Application - Launched!');
    });

    nsApp.on(nsApp.suspendEvent, (eventData: nsApp.ApplicationEventData) => {
      this.log.info('TNS Application - Suspended');
    });

    nsApp.on(nsApp.resumeEvent, (eventData: nsApp.ApplicationEventData) => {
      this.log.info('TNS Application - Resumed');
    });

    nsApp.on(nsApp.lowMemoryEvent, (eventData: nsApp.ApplicationEventData) => {
      this.log.warn('TNS Application - !!! LOW MEMORY !!!');
    });

    nsApp.on(nsApp.exitEvent, (eventData: any) => {
github linfaservice / cloudgallery / app / pages / gallery / gallery.component.js View on Github external
GalleryComponent.prototype.ngOnInit = function () {
        var _this = this;
        this.page.actionBarHidden = false;
        this.util.log("Page Init Gallery", null);
        if (application.android) {
            application.android.on(application_2.AndroidApplication.activityBackPressedEvent, function (data) {
                data.cancel = true; // prevents default back button behavior
                _this.back();
            });
        }
        /*
        applicationOn(resumeEvent, (args: ApplicationEventData)=> {
            this.loadGallery({path: this.path, nodeid: this.nodeid});
        });
        */
        application_1.on("orientationChanged", function (e) { _this.setOrientation(e); });
    };
    GalleryComponent.prototype.ngOnDestroy = function () {
github NativeScript / nativescript-cli-tests / data / apps / livesync-hello-world / app.js View on Github external
var application = require("application");
application.setCssFileName("./app.css");
application.start("main-page");

application

unified http and websocket api

Unknown
Latest version published 12 years ago

Package Health Score

28 / 100
Full package analysis

Popular application functions