IOS - the first network request ends after unlocking

I have an iOS app that retrieves user data from server in applicationDidBecomeActive.

If the user presses the home button and then returns to the application, either through the application icon or the multitasking screen, the function works fine.

If the user locks the device on average (either in the application, or when you click on the house, and then it is blocked), the network request fails. I am using Alamofire. The response object niland result.dataempty. The server also does not receive a request. Failure occurs instantly.

+4
source share
2 answers

Apple Tech Note TN2277, , ​​ , . :

Socket Reclaim

, , , , . , ; . (iOS 4.0 iOS 4.3), :

, , .

, Alamofire.Manager AppDelegateWillEnterForeground. , .

+4

applicationWillEnterForeground AppDelegate Network Manager, . , , . , , , .

     func applicationWillEnterForeground(_ application: UIApplication) {
            WebServiceManager.sharedInstance.sessionManr = Alamofire.SessionManager.default
            WebServiceManager.sharedInstance.sessionManr.session.configuration.requestCachePolicy = .reloadIgnoringLocalAndRemoteCacheData

            WebServiceManager.sharedInstance.sessionManr.session.configuration.urlCache = nil
            WebServiceManager.sharedInstance.sessionManr.session.configuration.timeoutIntervalForRequest =  180 //40
            WebServiceManager.sharedInstance.sessionManr.session.configuration.httpShouldSetCookies = true
     }
0

All Articles