afnetworking-2

AFNetworking 2.0 : Cannot POST with JSON from IOS

﹥>﹥吖頭↗ 提交于 2019-12-05 08:01:40
Ever since upgrading my IOS code to use AFNetworking version 2.0 instead of 1.x, I cannot do an HTTP Post any more with JSON parameters. I suspect it is because my HTTP request header is not "application/json" but I have tried to do that and it still does not work. This is my test code for trying to POST by JSON: NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys: email, @"email", password, @"password", nil]; [[OTApiClient sharedInstance] POST:@"login" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"result: %@", responseObject)

AFNetworking error 53 during attempted background fetch

孤街浪徒 提交于 2019-12-05 06:36:05
While updating my application to support Background App Refresh I ran into problem with AFNetworking. I am getting NSPOSIXErrorDomain Code=53 "Software caused connection abort" . The problem seems to occur in iOS 12, where the background connection gets terminated. AFNetworking 2.6.3 is used to make the fetch. AppDelegate.m : - (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [OrdersService performFetch]; completionHandler(UIBackgroundFetchResultNewData); } OrdersService.m : -(void) performFetch { [

AFNetworkReachabilityManager says no network

六眼飞鱼酱① 提交于 2019-12-05 04:49:47
I'm confused due to lack of examples, so I did this in my appDelegate's didFinishLaunching: [[AFNetworkReachabilityManager sharedManager] startMonitoring]; bool isThere = [[AFNetworkReachabilityManager sharedManager] isReachable]; And that always returns false, in spite of the network being there and working. Two questions: 1) if I'm not looking for changes in status, do I need startMonitoring? 2) is there anything you need to do before reading isReachable? Do you need to wait? Suryavel TR I know it's too late to answer. If anybody looking for this. Determining network status requires little

AFNetworking and Swift - Save json response

核能气质少年 提交于 2019-12-05 01:39:24
问题 I want to make a GET request in swift to get some Json data. I tried to use AFNetworking and it works, but I don't know how to return the Json I get. I tried with a return but it's made before the GET so I get nothing... func makeGet(place:String) -> String { var str:String = "" let manager = AFHTTPRequestOperationManager() manager.requestSerializer.setValue("608c6c08443c6d933576b90966b727358d0066b4", forHTTPHeaderField: "X-Auth-Token") manager.GET("http://something.com/api/\(place)",

A server with the specified hostname could not be found in AFNetworking

风流意气都作罢 提交于 2019-12-05 01:11:44
问题 I switch out AFnetworking API from ASIHTTPRequest in my app for connection error issues. But now I'm getting connection error in AFNetworking . How can I resolve this? Printing description of error: Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo=0x1553bab0 {NSErrorFailingURLStringKey=https://example.com/oauth/token, NSErrorFailingURLKey=https://example.com/oauth/token, NSLocalizedDescription=A server with the specified hostname

how to get return in AFHTTPRequestOperationManager request in afnetworking

限于喜欢 提交于 2019-12-04 20:03:19
Hi i am posting data in using AFHTTPRequestOperationManager class getting the response from server but not able to return data . method return is executed first then success data is coming i want to get the value in return . this is my code .h file @interface ServerRequest : NSObject { } -(NSString *) JsonData:(NSString *)newparams actionmethod:(NSString *)action parameters:(NSDictionary *)params; .m #import "ServerRequest.h" #import "AFNetworking.h" @implementation ServerRequest { } -(NSDictionary *) getJsonData:(NSString *)anynewparams actionmethod:(NSString *)action parameters:(NSDictionary

allow invalid certificates with AFNetworking

帅比萌擦擦* 提交于 2019-12-04 19:19:49
问题 I have been using following code AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request]; operation.allowsInvalidSSLCertificate=YES; Now i have changed AFNetworking to latest version that is 2.0. operation.allowsInvalidSSLCertificate is not working anymore with AFHTTPRequestOperation . As per documents i used AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.securityPolicy.allowInvalidCertificates = YES; and my

AFHTTPSessionManager posting video swift

半腔热情 提交于 2019-12-04 19:18:51
I am trying to upload a video in background using AFNetworking > AFHTTPSessionManager Post method. I want it to conitune uploading even if the app is suspended. But I get error while executing this code, it logs no error, and points to nowhere in code. I tried every solution available on other posts regarding my scenario, but couldn't get it working. Plesae check my code below and suggest me solution or link me somewhere to make it work { let urlString = BaseUrl + WebLinks.post let appId = NSBundle.mainBundle().bundleIdentifier let config = NSURLSessionConfiguration

AFNetworking 2.0 - How to download uiimage async

时光总嘲笑我的痴心妄想 提交于 2019-12-04 15:54:17
问题 In ios using AFNetworking 2.0 how can I easily download a remote image asynchronously and cache it for future request of the same url? I'm looking for a convenient way to receive both error callbacks and successful ones. Thanks 回答1: You can do AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; requestOperation.responseSerializer = [AFImageResponseSerializer serializer]; [requestOperation setCompletionBlockWithSuccess:^

AFNetworking 2.0: NSURLSessionDownloadTask is cancelled when received 302 to AWS S3

断了今生、忘了曾经 提交于 2019-12-04 13:11:11
I'm using a simple example from the README file (from AFNetworking 2.0 page) to download an image. All works fine for the images served directly from my web-sever. But for those located on the S3 the web-server returns 302 Redirect the following error: Error Domain=NSURLErrorDomain Code=-999 "cancelled" When I try to download the image (using the same code) directly from the S3 (omitting the redirection) I receive the same error. I've checked the availability of the actual image with wget. The image is publicly available ( https://youguide.s3.amazonaws.com/icons/user_96x96.png ). Anyone