NativeScript - App LifeCycle

说是LifeCycle 其实就是几个事件

这是配合angular2的
主要就是lauch resume suspend
exit事件我没看到触发过.可能是bug

import {nativeScriptBootstrap} from "nativescript-angular/application";
import {AppComponent} from "./app.component";
import * as application from 'application';
import {setStatusBarColors} from "./utils/status-bar-util";


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 Android application with the following intent: " + args.android + ".");
} else if (args.ios !== undefined) {
// For iOS applications, args.ios is NSDictionary (launchOptions).
console.log("Launched iOS application with options: " + 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("Activity: suspendEvent " + args.android);
} else if (args.ios) {
// For iOS applications, args.ios is UIApplication.
console.log("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("Activity: resumeEvent " + args.android);
} else if (args.ios) {
// For iOS applications, args.ios is UIApplication.
console.log("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("Activity: exitEvent" + args.android);
} else if (args.ios) {
// For iOS applications, args.ios is UIApplication.
console.log("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("Activity: " + args.android);
} else if (args.ios) {
// For iOS applications, args.ios is UIApplication.
console.log("UIApplication: " + args.ios);
}
});

application.on(application.uncaughtErrorEvent, function(args: application.ApplicationEventData) {
if (args.android) {
// For Android applications, args.android is an NativeScriptError.
console.log("NativeScriptError: " + args.android);
} else if (args.ios) {
// For iOS applications, args.ios is NativeScriptError.
console.log("NativeScriptError: " + args.ios);
}
});

setStatusBarColors();
nativeScriptBootstrap(AppComponent);