iosafnetworkingios9afhttpsessionmanager

afnetworking with iOS 9 sessions


I have that big project it's for some websites so I made a subclass from AFHTTPSessionManager as service class, everything was working fine till iOS 9 released, then login doesn't work I checked I get token and everything but I can't use them I mean when I request to see my cars for example server sends me that I am not logged in. I used those keys for server exception but didnt work. I am sorry for that lame question.


Solution

  • I solved my problem by adding this method to my subclass of AFHTTPSessionManager

    - (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request completionHandler:(void (^)(NSURLResponse *, id, NSError *))completionHandler{
    
    NSMutableURLRequest *req = (NSMutableURLRequest *)request;
    [req setValue:headerToken forHTTPHeaderField:@"header"];
    
    return [super dataTaskWithRequest:req completionHandler:completionHandler];}
    

    so it's like every time I create data task I will just force it to send the header.