I am creating app in which when user login i am hitting create session api and when user kill the app or not using the app i want to call delete session api. So how i can implement this feature
There isn’t a general solution to this problem. The applicationWillTerminate(_:)
delegate function that Claude31 mentioned is only called if the user removes your app from the multitasking UI while the app is running. If they do that while the app is suspended, or they just move it to the background and leave it there for long enough, the system doesn’t notify your app when it’s terminated.
As to what you should do, it depends on the semantics of this “session api”. In most cases these problems are best solved on the server side. Imagine, for example, if the user puts their phone, with your app running, into a Faraday cage. From the server’s perspective the app has just stopped responded on that session. Your server needs some way to handle that, regardless of this issue.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"