AFTNetworking in iOS 8.1.1 is in trouble?

0

I recently developed an app that uses AFTNetworking 2.0 and tested on my device using iPhone 4S iOS 8.0. However, iOS 8.1.1 customers can not send data from a registration.

Unfortunately, I do not have a device with iOS 8.1.1 and I do not intend to upgrade my iPhone for future testing purposes.

The app does not close or lock, but not only does it not submit the form.

The weirdest thing that works normally in emulators, and has even been approved by Apple and is already available in the Apple Store.

And there is an alert for success, and for failure to operate AFNetworking.

Has anyone had the same problem?

Code used:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

    // Importante
    AFJSONResponseSerializer *serializer = [AFJSONResponseSerializer serializer];
    [serializer setReadingOptions:NSJSONReadingAllowFragments];
    [manager setResponseSerializer:serializer];
     manager.responseSerializer = [AFHTTPResponseSerializer serializer];
     manager.requestSerializer.timeoutInterval = 120;
    // Importante

    [manager GET:urlStrin parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        // do whatever you'd like here; for example, if you want to convert
        // it to a string and log it, you might do something like:

        NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];



        if ([string isEqual: @"SENHA_NAO_CONFERE"]) {

            // Caso ocorra um erro e nao consiga salvar primeiro no webservice, ele também não salvará no banco local
            //return NO;
            app.networkActivityIndicatorVisible = NO;
            [self alertaVerificarSenha];
            flagVerdadeFalso = [self retornaFalso];


        }else{

            [self insereDadosAdvogadoBanco];

            [self alertadeSucesso];

            // 4 - Chama a tela com a lista de
            TelaPrevisualizacaoProcessoViewController*telaPrevisualizacao= [self.storyboard instantiateViewControllerWithIdentifier:@"telaPrevisualizacao"];

            [self presentViewController: telaPrevisualizacao animated: YES completion: nil];


            app.networkActivityIndicatorVisible = NO;
            flagVerdadeFalso = [self retornVerdade];

        app.networkActivityIndicatorVisible = NO;
       }

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

        app.networkActivityIndicatorVisible = NO;
        NSLog(@"Error: %@", error);
    }];
    
asked by anonymous 21.11.2014 / 22:42

1 answer

2

James,

At first I want to say that I use AFNetworking and it is working perfectly.

Then I have some questions about your problem:

1 - Are you sending, and do not print anything (error) in the log? 2 - Are you sending a form with GET and no parameters?

Finally, below is the way I use lib in my project:

AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] init];
manager = [AFHTTPRequestOperationManager manager];

If the query is to an API that uses OAUTH2, add the line below to validate the query:

[manager.requestSerializer setValue:[NSString stringWithFormat:@"%@ %@",
                                         @"TIPO_TOKEN",
                                         @"SEU_TOKEN"]
                     forHTTPHeaderField:@"Authorization"];

If the submit (POST, form-only) type of the form is JSON add the line below:

manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/json"];

For POST submissions:

[manager POST:strUrlRequest parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"ERROR: %@", [error description]);
}];

For queries with GET:

[manager GET:strUrlRequest parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

I hope I have helped. Thanks.

    
26.11.2014 / 19:43