本文整理汇总了TypeScript中tns-core-modules/application.on函数的典型用法代码示例。如果您正苦于以下问题:TypeScript on函数的具体用法?TypeScript on怎么用?TypeScript on使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了on函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: quickActionCallback
(() => {
const iconHandler = args => {
if (!args || !args.android || !args.android.getAction) {
return;
}
const launchAction = args.android.getAction();
const isShortcutAction = launchAction && launchAction.indexOf(SHORTCUT_PREFIX) > -1;
if (isShortcutAction) {
// "clear" the intent
args.android.setAction("");
const quickAction = {
type: launchAction.substring(SHORTCUT_PREFIX.length)
};
if (quickActionCallback) {
quickActionCallback(quickAction);
} else {
lastQuickAction = quickAction;
}
}
};
application.on("launch", (args) => iconHandler(args));
})();
示例2: Promise
return new Promise((resolve, reject) => {
if (_senderId !== null) {
resolve(_senderId);
}
const setSenderIdAndResolve = () => {
const senderIdResourceId = application.android.context.getResources().getIdentifier("gcm_defaultSenderId", "string", application.android.context.getPackageName());
if (senderIdResourceId === 0) {
throw new Error("####################### Seems like you did not include 'google-services.json' in your project! Firebase Messaging will not work properly. #######################");
}
_senderId = application.android.context.getString(senderIdResourceId);
resolve(_senderId);
};
if (!application.android.context) {
// throw new Error("Don't call this function before your app has started.");
appModule.on(appModule.launchEvent, () => setSenderIdAndResolve())
} else {
setSenderIdAndResolve();
}
});
示例3:
import { OptionsService } from "./navigation/options/options.service";
import { ExampleItemService } from "./navigation/exampleItemService.service";
import { ExamplesListDepthComponents } from "./navigation/examples-list/examples-list.component";
import { OptionsComponent } from "./navigation/options/options.component";
import { COMMON_DIRECTIVES } from './navigation/directives';
import { CommonDirectivesModule } from './navigation/directives/common-directives.module';
import { TNSImageModule } from "nativescript-image/angular";
// >> (hide)
import * as applicationModule from "tns-core-modules/application";
import * as imageModule from "nativescript-image";
if (applicationModule.android) {
applicationModule.on("launch", () => {
imageModule.initialize();
});
}
// << (hide)
@NgModule({
bootstrap: [
AppComponent
],
declarations: [
AppComponent,
ExamplesListDepthComponents,
OptionsComponent
],
imports: [
NativeScriptModule,
示例4: function
ďťżimport * as application from 'tns-core-modules/application';
application.on(application.launchEvent, function (args) {
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) {
if (args.android) {
// For Android applications, args.android is an android activity class.
console.log("Suspent Activity: " + args.android);
} else if (args.ios) {
// For iOS applications, args.ios is UIApplication.
console.log("Suspent UIApplication: " + args.ios);
}
});
application.on(application.resumeEvent, function (args) {
if (args.android) {
// For Android applications, args.android is an android activity class.
console.log("Resume Activity: " + args.android);
} else if (args.ios) {
// For iOS applications, args.ios is UIApplication.
console.log("Resume UIApplication: " + args.ios);
}
});
示例5: endsWith
import { on, resumeEvent, suspendEvent } from 'tns-core-modules/application';
export function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
export function nsArrayToJSArray(a) {
var arr = [];
if ("undefined" !== typeof a) {
var count = a.count;
for (var i = 0; i < count; i++) {
arr.push(a.objectAtIndex(i));
}
}
return arr;
}
export function newUUID(a?,b?){for(b=a='';a++<36;b+=a*51&52?(a^15?8^Math.random()*(a^20?16:4):4).toString(16):'-');return b}
let appSuspending = false;
on(suspendEvent, () => { appSuspending = true; });
on(resumeEvent, () => { appSuspending = false; });
export function isAppSuspending(): boolean {
return appSuspending;
}
示例6:
import { NgModule, NgModuleFactoryLoader, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NativeScriptUISideDrawerModule } from "nativescript-ui-sidedrawer/angular";
import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
import { CoreModule } from "./core/core.module";
import * as fresco from "nativescript-fresco";
import * as application from "tns-core-modules/application";
if (application.android) {
application.on("launch", () => {
fresco.initialize({ isDownsampleEnabled: true });
});
}
@NgModule({
bootstrap: [
AppComponent
],
imports: [
AppRoutingModule,
NativeScriptModule,
NativeScriptUISideDrawerModule,
CoreModule,
CoreModule.forRoot(),
],
declarations: [
AppComponent
],
schemas: [
示例7: require
ďťżimport "./bundle-config";
import * as application from 'tns-core-modules/application';
import { UnhandledErrorEventData } from "tns-core-modules/application";
// added this here so we can do some wiring
require("nativescript-plugin-firebase");
// testing this.. we may be able to hook that up to Crashlytics. Either via docs, or automatically.
application.on(application.uncaughtErrorEvent, (args: UnhandledErrorEventData) => {
console.log("[app.js]: Uncaught NativeScript Error: " + args.error);
});
application.run({ moduleName: "main-page" });
示例8:
import { routing } from "./app.routing";
import { OptionsService } from "./navigation/options/options.service";
import { ExampleItemService } from "./navigation/exampleItemService.service";
import { ExamplesListDepthComponents } from "./navigation/examples-list/examples-list.component";
import { OptionsComponent } from "./navigation/options/options.component";
import { COMMON_DIRECTIVES } from './navigation/directives';
import { CommonDirectivesModule } from './navigation/directives/common-directives.module';
import { TNSFrescoModule } from "nativescript-fresco/angular";
// >> (hide)
import * as applicationModule from "tns-core-modules/application";
import * as frescoModule from "nativescript-fresco";
if (applicationModule.android) {
applicationModule.on("launch", () => {
frescoModule.initialize();
});
}
// << (hide)
@NgModule({
bootstrap: [
AppComponent
],
declarations: [
AppComponent,
ExamplesListDepthComponents,
OptionsComponent,
],
imports: [
NativeScriptModule,