How can I close an Ionic 5 app from code?
Asked Answered
L

1

5

I can't find the way to close an app in Ionic 5 system. Looks like the way to do it in Ionic 4 is not working for Ionic 5. Is it possible to do?

Leia answered 7/4, 2020 at 8:42 Comment(0)
D
6
closeApp() { 
    this.platform.backButton.subscribeWithPriority(999999, () => { 
    navigator['app'].exitApp();
    // or trigger any action you want to achieve
    }) //Amended missing a closing bracket
}
Datnow answered 7/4, 2020 at 10:46 Comment(4)
I'm not sure that I need to connect it to back button now. But if i execute line navigator['app'].exitApp(); I get an error "TypeError: Cannot read property 'exitApp' of undefined". It looks like it works for Ionic 4, but I can't use it with Ionic 5.Lemma
I also use the latest version of ionic but it works normally for me, i don't know wrong with your project maybe, but from like 5 days i finished a project and it was working , so don't know if a new version has been released and it became not working.Datnow
Sorry if this sounds dumb, where do I put this code? I am using Ionic 5 with vue.Spigot
I am not much familoar with vue, but usually, it cam be but on main app holder, like app.component.js or app.js , and u put it in the constructor of the page, and it should work.Datnow

© 2022 - 2024 — McMap. All rights reserved.