Get active view from app component using Nav Controller

I’m using tabbed navigation and I’m trying to get the active view from a function I call from my app component. A user could be on any view in the app when this function is called.

But when I call getActive() from within that function, the Nav Controller (which I am getting as @ViewChild in my app component) always returns the Tab View Controller as the active view controller.

 @ViewChild('Nav') navCtrl:NavController;

  let nav = this.navCtrl;
  nav.getActive() // returns the Tabs View Controller regardless of the view it is called from

As a result, I am unable to get the active view controller from the page that actually is the active view. Is there another way to get the active view from a function that resides in the app controller but can be called from any view in the app?

I would look for another way to achieve your ultimate goal. Every time I have found myself wanting to do such cross-component fiddling I have ended up regretting it.

Thanks Robert, I am wondering what you would suggest? I won’t have control over where users are in the app when this function is triggered (it comes from a push notification), and I’d like to know where they are coming from when it fires so I can manage navigation in an expected way.

What I would do in that situation is to decentralize control. Have whatever is receiving the push notification expose some sort of Observable reflecting when they come in, and have the various pages that need to react to it in different ways subscribe to it when they become active and unsubscribe when they become inactive.