Nach ein paar Stunden kämpfen, ich hoffe, ich kann jemanden finden, der das versteht. Nativescript bietet Unterstützung für Anwendungsereignisse für Angular + Typoskript:Nativescript Angular - Verwenden von Anwendungsereignissen
http://docs.nativescript.org/angular/core-concepts/application-management.html
Allerdings verstehe ich nicht, wo ich diese hinzufügen sollten. Das Beispiel von der Website zeigt den folgenden Code:
import application = require("application");
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.start({ moduleName: "main-page" });
Wie kann ich das innerhalb meiner Angular-Anwendung verwenden? Für mich fühlt es sich an, als wäre das nicht Code für die Angular-Version, aber vielleicht fehlt mir etwas.
Ich habe versucht, die Anwendung importieren und die ngOnInit meiner Haupt AppComponent fügte hinzu:
ngOnInit() {
application.on(application.launchEvent, function (args: application.ApplicationEventData) {
if (args.android) {
// For Android applications, args.android is an android.content.Intent class.
console.log("Alert something"); // : " + args.android + ".");
} else if (args.ios !== undefined) {
// For iOS applications, args.ios is NSDictionary (launchOptions).
console.log("Launched iOS application with options: " + args.ios);
}
console.log('launch detected')
});
console.log('application initiated');
}
Obwohl ich keine Fehler bekommen, erhalte ich nur die Anwendung initiiert Meldung. Irgendeine Idee, wie ich die erwähnten Android-Argumente verwenden kann?
Update: Am Ende, als es war viel einfacher zu erwarten, bitte den Code ich das gebraucht zu beheben:
import app = require('application');
import "reflect-metadata";
import {nativeScriptBootstrap} from "nativescript-angular/application";
import {AppComponent} from "./app.component";
app.on(app.launchEvent, function (args: app.ApplicationEventData) {
// on launch code
});
nativeScriptBootstrap(AppComponent);
Danke für Ihre Hilfe!
Es gibt keine application.start in meinem Winkel Projekt ist, alles, was ich sehe, ist: nativeScriptBootstrap (AppComponent) ; – visscher
Ich werde diese Antwort als die richtige Antwort markieren, denn am Ende hat es mir geholfen, es zu lösen. Vielen Dank! – visscher