How to handle app close in Lightning

Hi Team ,

If we want to exit application,we are handling the exit of the application using this.application.closeApp();
In Browser it works and shows a log as app has been closed,but when we try it on RDK devices ,its just staying in the same screen,please suggest any points

Hi Sharan!

Lightning itself doesn’t have any platform specific handling of what to do on a certain device. For every integration on a specific platform, be it RDK/Tizen/WebOS or something else this will need to be handled accordingly.

Sometimes the platform SDK, such as Firebolt or Metrological SDK will handle this for you. Or you might want to implement it yourself. Eitherway Lightning doesn’t provide platform specific handling.

In your case, can you help me understand what you are trying to do, are you:

  • Trying to close the browser? And refocus another open browser session? or;
  • Trying to reload another URL when you close the app? Like go to another destination?
  • Go to another application?

Also how are you planning to host the application? Are you going to host it yourself or are you using one of the app platforms?

This will help me guide you to the resources that you require to do that.

Hi @Sharan .

When we submitted to the Metrological app store, we were told to use the following hook, under the App.js file (assuming you’re using a router)

 _handleAppClose() {
      this.application.closeApp();
  }

The relevant documentation can be found here:

However, as Wouter mentioned, it really depends on the platform. If you’re not publishing to the Metrological app store, you’ll probably have to use the exit method on the platform you intend running your app.

Hi @eduardo.guzman,

As of version 4.8.3 of the Lightning SDK, that _handleAppClose() hook is no longer needed if you just want to close the app directly once the router history is empty.