简体   繁体   中英

Alamofire not working while called from background fetch

I'm using background fetch in an iOS app to schedule some notifications and I need to fetch some data from server But when i create an Alamofire request the surver returns the data but alamofire does not calles my compilation handler (responseString)

the exact same code works perfectly while my app is on forground.

Alamofire.request(url, method: method ?? HTTPMethod.get, parameters: parameters,
        encoding: encoding ?? URLEncoding.default, headers: headers)
        .responseString{
        (afResponse : DataResponse<String>) -> Void in
    ....
}

I used AlamofireNetworkActivityLogger to check weather the response is created and fetched and the result was true. but my compilation handler not getting called!

any thing else should I consider while using Alamofire in background?

Have you tested if it is working as suggested in Alamofire network calls not being run in background thread

We may have to start the call from background thread instead of the main thread (as it is the default behaviour).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM