SCNetworkReachability updated too late on iOS 8

Originator:pierre.oleo
Number:rdar://17977029 Date Originated:11-Aug-2014
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 8.0 12A4331d
Classification: Reproducible:
 
Summary:
In iOS 7 when an NSURLConnection is downloading and the device connection gets lost, (like when switching to airplane mode), the NSURLConnection handler is triggered with a connection error like NSURLErrorNotConnectedToInternet. If the application checks SCNetworkReachabilityFlags (through Reachability or directly), the response will be that the application is currently not connected so we can be sure that throughout the application all completions will be handled just fine as any check will return the correct value.

In the same case on iOS 8 when the device connection gets lost, the NSURLConnection handler is stll triggered with a connection error like NSURLErrorNotConnectedToInternet. However, if the application checks SCNetworkReachabilityFlags the response will be that the application is currently still connected which can be difficult to handle as the connection obviously knows the device is not connected but the only way we have to check for the status returns a false positive.

Steps to Reproduce:
1) in an application, launch a long download through NSURLConnection
2) switch to airplane mode before the end of the download 

Sample available at https://github.com/eKaiju/RDAR_Reachability_IOS8

Expected Results:
1) The connection handler is called with a connection error like NSURLErrorNotConnectedToInternet
2) if we check for SCNetworkReachabilityFlags or  [[Reachability reachabilityForInternetConnection].currentReachabilityStatus we get informed that application is not connected 
That's the current result in iOS 7

Actual Results:
1) The connection handler is called with a connection error like NSURLErrorNotConnectedToInternet
2) if we check for SCNetworkReachabilityFlags or  [[Reachability reachabilityForInternetConnection].currentReachabilityStatus we get informed that application is currently connected 

Notes:
Sample demonstrating the problem on github https://github.com/eKaiju/RDAR_Reachability_IOS8

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!