IonicApp or App?


#1

I don’t know the difference between these two components or their intent. I know that App has an entry in the API Docs but IonicApp has none. My IDE (VSCode) tells me that IonicApp has some hidden members (underscored names, sometimes annotated). I’ve seen code examples using an instance of this class but I still don’t understand why there is an injectable IonicApp and App or what should I expect to use them for.

Could anyone clarify intended use? Is there any documentation for IonicApp?

I’ll leave a summarized code snippet that I am expected to use below. It is part of the back-button handler registration code

let activePortal = (
	this.ionicApp._loadingPortal.getActive() ||
	this.ionicApp._modalPortal.getActive() ||
	this.ionicApp._toastPortal.getActive() ||
	this.ionicApp._overlayPortal.getActive()
);

if (activePortal) {
	activePortal.dismiss();
	activePortal.onDidDismiss(() => {});
	return;
}

###global packages:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 6.5.0 
Ionic CLI        : 3.4.0

###local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : android 6.1.2
Ionic Framework                 : ionic-angular 3.2.1

#2

The entire IonicApp class is annotated @hidden, which I take to mean that we should not be interacting with it at all, period.


#3

If that is so, then could you point me out to a way in which the app can determine that some overlay is open so that I can close it? Or should I be setting up my own global service to track down any dismissables so the AppComponent knows about them?
As far as I can understand, the code above simply attempts to locate any dismissable component open/active (that is not a page) and dismisses it if found. I am not so sure how I could do this another (“correct”) way at the moment.
I have the feeling that each page should handle it’s own dismissables which means I’ll be duplicating a lot of handler code in every page, while the global back button handler in AppComponent should be a last resort back button. Am I on the right track?


#4

Have you found any help on this topic or a better way to achieve this functionality, Because i’m struggling with the same thing… i tied importing IonicApp into a service but that just breaks the application(white screen).