Sorry for duplication of question, after long research on the issue that "how to Call an Api in applicationWillTerminate()" but found nothing. There was two solution but some how the are not working for me. solution Found: Can I make an api call when the user terminates the app?
Asked
Active
Viewed 612 times
1
-
I don't believe you will find a solution that is reliable. Remember that in many cases, particularly when the user swipes up on your app from the switcher, `applicationWillTerminate` *is not called*. – Paulw11 Jun 18 '21 at 12:59
-
1*Terminating* the app is like a force quit in macOS. In both cases `applicationWillTerminate` is not called. In iOS it’s recommended anyway to save changes instantly. – vadian Jun 18 '21 at 13:02
1 Answers
2
You can't call API if your app is in applicationWillTerminate state or application in killed state.
Application only allows to save instant changes in applicationWillTerminate state
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Saves changes in the application's managed object context before the application terminates.
CoreDataManager.sharedManager.saveContext()
}

Protocol
- 1,696
- 13
- 30