Closed pti closed 9 years ago
Hi! 1) Blocks in 'init' method looks not very good. Sorry)) 2) Your changes destroy backward compatibility with previous versions. Many users will be unhappy after update 3) There are better way to fix this bug. Just run 'observeChanges' block immediately if networks status is valid. Like in 'reachabilityStatus' method.
Thank you for the bug. I'll fix it
Fixed. New release 2.0.3 is on cocoapods
Hi,
Thanks for the feedback.
Unfortunately the fix done for 2.0.3 doesn't seem to fix the issue. If SCReachabilityScheduler.callbackForReachabilityRef
is called before SCReachabilityScheduler.observeStatusChanges
then the application never gets the first status event.
This happens in my tests about 50% of the time on the iPhone4 7.1.2.
Perhaps SCReachabilityScheduler
could store the status in the case where callbackForReachabilityRef
is called and statusChangesBlock
is still nil
. Then later when statusChangesBlock
is set the stored status would be passed to the block immediately?
Thanks for feedback. I'll check it
Oh, there are still a bug. You are right! Hope I finally fix it. Check out version 2.0.4 on cocoapods
This issue occurred in an app that called SCNetworkReachability.initWithHost: from application:didFinishLaunchingWithOptions:. In SCNetworkReachability.initWithReachabilityRef: the method SCReachabilityScheduler.initWithReachabilityRef: is called before setting statusChangesBlock with method observeStatusChanges:. In some cases SCReachabilityScheduler.callbackForReachabilityRef callback function could get called before observeStatusChanges: got called -> statusChangesBlock was nil and the callback got ignored. So the app didn't get notified of the network status until it changed again. This issue was quite easy to reproduce with an iPhone4 (7.1.2) with WiFi connection (no SIM card was inserted).
The fix was to pass the statusChangesBlock in the SCReachabilityScheduler.initWithReachabilityRef method.