I've got the below code in sceneDidDisconnect Delegate, letting the backend know that the user is no longer online when the app is being closed. The print statement gets executed but not the api call. I don't get why that is or how / where else I would alternatively call the api prior to the app closing down.
func sceneDidDisconnect(_ scene: UIScene) {
print("************************sceneDidDisconnect***********************************")
// set offline
guard let userId = UserDefaults.standard.string(forKey: "userId") else { return }
self.apiService.setOnline(online: false, userId: userId) { (result) in
// handle result
}
}