Ionic App Force Close

Hi,

I would like to disconnect from my server when the user triggers a force close of the app on their android/ios device using their respective built in app managers. Is there any way for me to know when a user closes my app?

I have tried ionViewWillLeave and ionVewDidLeave but both do not seem to be working:

  ionViewWillLeave() {
    // disconnect from server
  }

  ionViewDidLeave() {
   // disconnect from server
  }

Any suggestions?

As it is hard to predict if a call to *WillLeave will happen, best solution will be on your server side. based on your connection, you can place an idle timeout on the connection, and drop the session if this idle reached.