I want to hit an API to set the last active time of the user. But the API is not hitting. As time is taken by the API to initialize and hit the server and before the API hit starts, the application got closed
I tried this code in my app.component.ts file
@HostListener('window:beforeunload', [ '$event' ])
beforeUnloadHander(event) {
this._apiService.setLastActive({time:new Date().getTime()/1000})
.subscribe(data => {
},err=> {
})
}
Can anybody suggest when can I call the API to set the last active status of the user?