this.platform.registerBackButtonAction(() => {
let activePortal = this.ionicApp._loadingPortal.getActive() ||
this.ionicApp._modalPortal.getActive() ||
this.ionicApp._toastPortal.getActive() ||
this.ionicApp._overlayPortal.getActive();
let view = this.nav.getActive();
let currentRootPage = view.component.name;
if (activePortal) {
activePortal.dismiss();
}
else if (this.menuCtrl.isOpen()) {
this.menuCtrl.close();
}
else if (this.nav.canGoBack() || view && view.isOverlay) {
this.nav.pop();
}
else if (currentRootPage == "HomePage") {
let alert = this.alertCtrl.create({
title: 'Sair da app ?',
message: '',
buttons: [
{
text: 'Cancelar',
role: 'cancel',
handler: () => {
alert.dismiss();
}
},
{
text: 'ok',
handler: () => {
this.platform.exitApp(); <-- HERE I NEED MINIMIZE APP(NO EXIT)
}
}
]
});
alert.present();
} else if (currentRootPage == "OrcamentoPage") {
let alert = this.alertCtrl.create({
title: 'Deseja fazer logoff ?',
message: '',
buttons: [
{
text: 'Cancelar',
role: 'cancel',
handler: () => {
alert.dismiss();
}
},
{
text: 'ok',
handler: () => {
this.nav.setRoot(HomePage);
}
}
]
});
alert.present();
}else if (currentRootPage == "PreferenciasPage") {
this.nav.setRoot(OrcamentoPage);
} else if (currentRootPage == "CarrinhoPage") {
this.nav.setRoot(OrcamentoPage);
} else if (currentRootPage == "FinalizaPage") {
this.nav.setRoot(OrcamentoPage);
} else if (currentRootPage == "ConfigPage") {
this.nav.setRoot(HomePage);
}
});
StatusBar.styleDefault();
Splashscreen.hide();
});
Try the native plugin (android only): https://ionicframework.com/docs/native/app-minimize/
LolStats where are you my friend ?
You are mixing Ionic Native v2 (ionic-native
) with v3 (@ionic-native
). You should upgrade everything to v3 first. Then probably also do what it says at the bottom here: https://ionicframework.com/docs/native/
Oh, and please don’t bump posts after a few minutes or hours. That’s impolite.
now i have that error: Runtime Error
Error in :0:0 caused by: No provider for AppMinimize!
I think that’s pretty clear…
Typescript Error
Property ‘plugin’ does not exist on type ‘MyApp’.
C:/xampp/htdocs/ionic2project/src/app/app.component.ts
handler: () => {
this.plugin.minimize().then(
success => console.log(‘Closed’),
this.appMinimize.minimize()
Thanks my friend!!!