How detect launch application event from main-page.js

plugins

#1

var application = require(“application”);
application.start({
moduleName: “main-page”
});
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 + “.”);
} ;
});

this code when i run on app.js is detect the Launch event but from main-page.js is not working


#2

I believe the application events should be specified before application.start. See here:
https://docs.nativescript.org/core-concepts/application-lifecycle

Since the main page loads AFTER the app is initialized, I’m guessing that’s why it doesn’t work.


#3

i find solution by importing my functions from main-page.js to app.js