afnetworking-2

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

亡梦爱人 提交于 2019-12-03 17:04:48
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 could not be found., NSUnderlyingError=0x1553b2c0 "A server with the specified hostname could not be found

allow invalid certificates with AFNetworking

和自甴很熟 提交于 2019-12-03 13:05:56
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 request code is AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];

AFNetworking 2 authentication with AFHTTPRequestOperation

大城市里の小女人 提交于 2019-12-03 12:38:29
问题 I want to use AFNetworking with a batch operation. I want to download 3 json files. How to add basic authentication with AFHTTPRequestOperation ? NSMutableArray *mutableOperations = [NSMutableArray array]; for (NSString *fileURL in filesToDownload) { NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:fileURL]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation

How to upload task in background using afnetworking

a 夏天 提交于 2019-12-03 12:31:46
I'm trying to upload large files using AFNetworking and have the upload continue when the application is in the background. I can upload files just fine, but when I attempt to use a background configuration -- the application crashes with the following stacktrace: Exception: EXC_BAD_ACCESS (code=1, address=0x8000001f)) _CFStreamSetDispatchQueue -[__NSCFBackgroundDataTask captureStream:] __70-[__NSCFBackgroundDataTask _onqueue_needNewBodyStream:withCompletion:]_block_invoke_2 _dispatch_call_block_and_release _dispatch_queue_drain _dispatch_queue_invoke _dispatch_root_queue_drain _dispatch

How to automatically refresh expired token with AFOAuth2Manager?

浪子不回头ぞ 提交于 2019-12-03 09:32:35
问题 I'm writing a small iOS client for a server protected with OAuth2. I'm wondering if is it possible using AFOAuth2Manager [here] auto-refreshing the expired token. The idea is that the logic for refreshing the client when the server responds with a 401, or raise an error when the refresh method returns a 401 should be quite common, so probably it is integrated in some library. 回答1: I created a subclass of AFOAuth2Manager In this subclass I override this method: - (AFHTTPRequestOperation *

iOS - Increase timeout for AFHTTPRequestOperationManager

倾然丶 夕夏残阳落幕 提交于 2019-12-03 09:08:45
问题 I'm downloading JSON data from a very slow server. It takes about a minute to get a resoonse from the server. I use AFNetworking library and my code throws "The request timed out" error: NSString *urlString = [NSString stringWithFormat:@"%@/account.do?JSON&sysparm_action=getRecords",baseUrlString]; NSString *login = [[NSUserDefaults standardUserDefaults] objectForKey:@"login"]; NSString *password = [[NSUserDefaults standardUserDefaults] objectForKey:@"password"]; [manager setRequestSerializer

AFNetworking 2.0 - How to download uiimage async

怎甘沉沦 提交于 2019-12-03 08:57:49
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 Bot You can do AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; requestOperation.responseSerializer = [AFImageResponseSerializer serializer]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"Response: %@", responseObject); _imageView.image =

AFNetworking 2.0 multipart request body blank

天大地大妈咪最大 提交于 2019-12-03 08:39:33
Similar to this issue . Using AFNetworking 2.0.3 and trying to upload an image using AFHTTPSessionManager's POST + constructingBodyWithBlock. For reasons unknown, it seems as though the HTTP post body is always blank when the request is made to the server. I subclass AFHTTPSessionManager below (hence the usage of [self POST ...] . I've tried constructing the request two ways. Method 1 : I just tried to pass params and then add only the image data should it exist. - (void) createNewAccount:(NSString *)nickname accountType:(NSInteger)accountType primaryPhoto:(UIImage *)primaryPhoto { NSString

Transition from RestKit to pure AFNetworking 2.0

爱⌒轻易说出口 提交于 2019-12-03 06:47:50
问题 I'd been using RestKit for the last two years, but recently I've started thinking about transition from these monolith framework as it seems to be really overkill. Here's my pros for moving forward: There is big need in using NSURLSession for background fetches and RestKit has only experimental branch for transition to AFNetworking 2.0. No actual dates when transition will be finished. (Main Reason) No need for CoreData support in network library as no need for fully functional offline data

AFHTTPSessionManager add body to POST

本秂侑毒 提交于 2019-12-03 05:59:06
I need too make a post request to my server. With AFHTTPRequestOperation is very simple just use: [request setHTTPBody: [requestBody dataUsingEncoding:NSUTF8StringEncoding]]; However i can't find any example how use the same approach using the AFHTTPSessionManager . Using the method: [self POST:@"extraLink" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { } success:^(NSURLSessionDataTask *task, id responseObject) { } failure:^(NSURLSessionDataTask *task, NSError *error) { }]; How i add the the body to the "AFMultipartFormData"? Thanks in advace As taken from the