Aftnetworking on iOS 8.1.1 is having problems?

Asked

Viewed 73 times

0

I recently developed an app that uses Aftnetworking 2.0 and ran tests on my physical device using iPhone 4S iOS 8.0. But customers who are with iOS 8.1.1 can not send the data of a registration.

Unfortunately I don’t have a device with iOS 8.1.1 and I don’t intend to update my iPhone for future testing.

The app neither closes nor hangs, but not only does it not send the form.

The weirdest that works normally on emulators, and has even been approved by Apple and is now available on the Apple Store.

And there is a warning for success, and for failure in the operation of Afnetworking.

Someone 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);
    }];
  • What specific method are you using @Tiago Amaral ? Here I am using Afnetwork on iOS 8.0, 8.1, 8.1.1 and 8.2 hassle-free.

  • Edited question! I put the source code used.

  • The strange thing is that the app doesn’t lock, not the error message, and it doesn’t shut down. It keeps running normal, and the user manages to navigate it as if nothing is wrong. Unfortunately I do not have an iPhone 5/6 to perform the tests in Xcode.

1 answer

2


James,

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

Then I have some doubts about your problem:

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

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

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

If the query is 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 submission type (POST, only for this) of the form is JSON add the line below:

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

For shipments with POST:

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

For consultations 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 helped. Hug.

  • I could not do Debug because the error only happened with iPhone 5 and 6. And I don’t have these devices in my hands for foreheads. Who tested was the coiente. And he lives in another state. So I removed the use of Aftnetworking.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.