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.
Asked
Active
Viewed 437 times
0
-
Have you added network permissions in info.plist > NSAppTransportSecurity – Raheel Sadiq Sep 21 '15 at 10:02
-
yes, but didn't work. – Hady Nourallah Sep 21 '15 at 10:10
-
everything works, but when I want to make request to get something for me as a user, server doesn't see. I think it doesn't see the session or something. – Hady Nourallah Sep 21 '15 at 10:13
-
you seem to have been working with AFHTTPSessionManager, I am kinda stuck in such issue too, can you have a look http://stackoverflow.com/questions/32689244/afhttpsessionmanager-posting-video-swift – Raheel Sadiq Sep 21 '15 at 10:14
-
hey racheel I solved my problem. (I wrote it in answer, I don't know if you saw or not.) can you send me if it worked for you or not :) – Hady Nourallah Sep 21 '15 at 16:21
-
its Raheel :) I solved my problem with using native NSURLSession, but I couldn't get AFHTTPSessionManager woking, but see if you can answer that question. Question link is in above comments. – Raheel Sadiq Sep 22 '15 at 06:01
2 Answers
1
If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible.
For a quick hack you can do the following,
Add this to the Info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

Vikram Jain
- 24
- 2
1
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.

Hady Nourallah
- 442
- 4
- 12