iOS Afnetwork 3.0 crash: Attempted to create a task in a session that has been invalidated

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


iOS Afnetwork 3.0 crash: Attempted to create a task in a session that has been invalidated



I am getting a rare crash when I invalidate and cancel AFNetwork session when a user logs out. This is the code I am using right now.


[manager.session invalidateAndCancel];



However, this doesn't work all the time. I get the following crash error.



Attempted to create a task in a session that has been invalidated



This is what requests are being made usually from the App before users logs out and it crashes (I simplified it).


- (void)getFirstData {
[manager GET:url
parameters:nil
progress:nil
success:^(NSURLSessionTask *task, id responseObject) {
[self getSecondData];
}
failure:^(NSURLSessionTask *operation, NSError *error) {

}];
}

- (void)getSecondData {
[manager GET:url
parameters:nil
progress:nil
success:^(NSURLSessionTask *task, id responseObject) {

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

}];
}









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

CRM reporting Extension - SSRS instance is blank

Keycloak server returning user_not_found error when user is already imported with LDAP