How to use the tns-core-modules/application.ios 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 / tests / app / application / application-tests.ios.ts View on Github external
//// Add custom application delegate
if (app.ios) {
    class MyDelegate extends UIResponder implements UIApplicationDelegate {
        public static ObjCProtocols = [UIApplicationDelegate];

        applicationDidFinishLaunchingWithOptions(application: UIApplication, launchOptions: NSDictionary): boolean {
            return true;
        }

        applicationDidBecomeActive(application: UIApplication): void {
            // Get reference to the application window.
            //console.log("keyWindow: " + application.keyWindow);
        }
    }

    app.ios.delegate = MyDelegate;
}

// << application-ios-delegate

export function testIOSApplicationInitialized() {
    TKUnit.assert(app.ios, "iOS application not initialized.");
    TKUnit.assert(app.ios.delegate, "iOS delegate not initialized.");
    TKUnit.assert(app.ios.nativeApp, "iOS nativeApp not initialized.");
    TKUnit.assert(app.ios.orientation, "iOS orientation not initialized.");
    TKUnit.assert(app.ios.window, "iOS window not initialized.");
    TKUnit.assert(app.ios.rootController, "iOS root controller not initialized.");
}
github bitwarden / mobile / app / app.ts View on Github external
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);
    }
});

app.on(app.uncaughtErrorEvent, (args: app.UnhandledErrorEventData) => {
    console.log('Error: ' + args.error);
});

if (app.ios != null) {
    class BitwardenApplicationDelegate extends UIResponder implements UIApplicationDelegate {
        static ObjCProtocols = [UIApplicationDelegate];
        static serviceContainer: ServiceContainer = null;

        applicationDidFinishLaunchingWithOptions(application: UIApplication,
            launchOptions: NSDictionary): boolean {
            console.log('applicationWillFinishLaunchingWithOptions: ' + launchOptions);
            BitwardenApplicationDelegate.serviceContainer = new ServiceContainer();
            BitwardenApplicationDelegate.serviceContainer.init();
            BitwardenApplicationDelegate.serviceContainer.bootstrap();
            appMain.init();
            return true;
        }

        applicationDidBecomeActive(application: UIApplication): void {
            console.log('applicationDidBecomeActive: ' + application);
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
github leandrorlls / nativescript-microsoft-appcenter / demo-ng / app / 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.module";
import * as application from 'tns-core-modules/application';
import { AppCenterSettings, AppCenter } from "nativescript-microsoft-appcenter";

if (application.ios){
    let appCenterSettings: AppCenterSettings = {
        appSecret: "",
        analytics: true,
        crashes: true,
        distribute: true,
    }

    let appCenter = new AppCenter();
    appCenter.startWithAppDelegate(appCenterSettings);
}

platformNativeScriptDynamic().bootstrapModule(AppModule);
github EddyVerbruggen / nativescript-ar / src / nodes / ios / arvideo.ts View on Github external
videoPlayer = AVPlayer.playerWithURL(nativeUrl);

    } else {

      if (video instanceof AVPlayer) {
        videoPlayer = video;
      } else if (video.ios && video.ios instanceof AVPlayer) {
        videoPlayer = video.ios;
      }
    }

    materialPlane.firstMaterial.diffuse.contents = videoPlayer;
    materialPlane.firstMaterial.doubleSided = true;

    if (options.loop !== false) {
      const AVPlayerItemDidPlayToEndTimeNotificationObserver = application.ios.addNotificationObserver(
          AVPlayerItemDidPlayToEndTimeNotification,
          (notification: NSNotification) => {
            // const player = this.plane.firstMaterial.diffuse.contents;
            if (videoPlayer.currentItem && videoPlayer.currentItem === notification.object) {
              videoPlayer.seekToTime(CMTimeMake(5, 100));
              videoPlayer.play();
            }
          }
      );
    }
    if (options.play !== false) {
      videoPlayer.play();
    }

    const node = SCNNode.nodeWithGeometry(materialPlane);
    // node.addAudioPlayer(SCNAudioPlayer);
github Notalib / nativescript-webview-ext / tests / app / TKUnit.ts View on Github external
export function waitUntilReady(isReady: () => boolean, timeoutSec: number = 3, shouldThrow: boolean = true) {
    if (!isReady) {
        return;
    }

    if (Application.ios) {
        const timeoutMs = timeoutSec * 1000;
        let totalWaitTime = 0;
        while (true) {
            const begin = time();
            const currentRunLoop = utils.ios.getter(NSRunLoop, NSRunLoop.currentRunLoop);
            currentRunLoop.limitDateForMode(currentRunLoop.currentMode);
            if (isReady()) {
                break;
            }

            totalWaitTime += time() - begin;
            if (totalWaitTime >= timeoutMs) {
                if (shouldThrow) {
                    throw new Error("waitUntilReady Timeout.");
                } else {
                    break;
github anihalaney / rwa-trivia / projects / trivia / src / app / components / app / app.component.tns.ts View on Github external
ngOnInit() {
    this.checkForceUpdate();
    if (application.ios && application.ios.window.safeAreaInsets) {
      const bottomSafeArea: number = application.ios.window.safeAreaInsets.bottom;

      console.log('safe are<>', bottomSafeArea);
      this.bottomSafeArea = bottomSafeArea > 0 ? this.bottomSafeArea + bottomSafeArea : this.bottomSafeArea;
    }
    firebase.init({
      onMessageReceivedCallback: (message) => {
        console.log('message', message);
        if (message.foreground) {
          this.utils.showMessage('success', message.body);
        }
        this.ngZone.run(() => this.navigationService.redirectPushRoutes(message.data));
      },
      showNotifications: true,
      showNotificationsWhenInForeground: true
    }).then(
      () => {
github NativeScript / nativescript-marketplace-demo / app / examples / chart / view-model.ts View on Github external
private getPictureResourcePath(groupName: string, exampleName: string) {
        if (app.ios) {
            return "res://chart/" + groupName + "/" + exampleName;
        }
        var resourcePath = "res://" + exampleName;
        return resourcePath;
    }
github nstudio / nativescript-videoplayer / videoplayer.ios.ts View on Github external
if (this.controls !== false) {
      this._playerController.showsPlaybackControls = true;
    }

    this._playerController.player = this._player;

    if (isNaN(this.width) || isNaN(this.height)) {
      this.requestLayout();
    }

    if (this.muted === true) {
      this._player.muted = true;
    }

    if (!this._didPlayToEndTimeActive) {
      this._didPlayToEndTimeObserver = application.ios.addNotificationObserver(
        AVPlayerItemDidPlayToEndTimeNotification,
        this.AVPlayerItemDidPlayToEndTimeNotification.bind(this)
      );
      this._didPlayToEndTimeActive = true;
    }
  }
github leandrorlls / nativescript-microsoft-appcenter / src / microsoft-appcenter.ios.ts View on Github external
public startWithAppDelegate(settings: AppCenterSettings): void {
        AppCenterDelegate.setup(settings);
        application.ios.delegate = AppCenterDelegate;
    }