Search code examples
kaios

Don't know how to kill app process in KaiOS


I am developing an app that uses ws connection on KaiOS. When I press back and put the app in the background, somehow the app instance is not killed. I can still get message coming in from ws connection even though the app is in background. This makes the phone runs out of battery quickly because exited app remains in the runtime process I suppose.

But, I do need a situation where the app runs in background (not killed).

So, the question is, do we have access to kill an app process, for example when user press something or normally when app is closed and screen back to menu screen from app screen?


Solution

  • I think you can observe the Backspace key and close the window.

    Such as:

    function handleKeydownEvent(e) {
      if (e.key == 'Backspace') {
        e.preventDefault();
        window.close();
      }
    }
    
    document.body.addEventListener("keydown", handleKeydownEvent);