Nativescript change tab at resume

ios
android

#1

Hi,

can i change tab (of tabview) when app is resumed in applicationDidBecomeActive (IOS) ?


#2

Listen for resume event and update the selectedIndex of the TabView.

https://docs.nativescript.org/core-concepts/application-lifecycle


#3

Thanks a lot for the answer.
I have this code in main.ts of my application

applicationOn(resumeEvent, function (args: 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);
    }
});

but how do I access the selectedIndex instance variable in my TabComponent?


#4

That’s up to your code, where ever you have defined TabView keep it accessible in the resume event. Or you can event get the current page from frame then traverse down to get the TabView or setting an id also works.


#5

Thanks for the reply,
I solved by entering the code written previously directly into the TabComponent.