How to Call an API in applicationWillTerminate( ) and get some time for response from the server

827 views Asked by At

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?

1

There are 1 answers

0
Protocol On BEST ANSWER

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()
}