Reachability icon indicating copy to clipboard operation
Reachability copied to clipboard

reachableBlock will be called twice in iOS9

Open jasminelily opened this issue 10 years ago • 6 comments

Hello Tony

Reachability 's reachableBlock will be called twice in iOS9.

I didn't see any report in there...

Can you check that?

Thanks

jasminelily avatar Sep 16 '15 10:09 jasminelily

hi, same for me, reachableBlock called twice

IlyaSukhikh avatar Sep 16 '15 20:09 IlyaSukhikh

Same for us as well.

kaylanx avatar Sep 18 '15 13:09 kaylanx

I've been doing some tests around this, and it's actually a problem with Apple's SCNetworkReachabilty API. Sometimes the SCNetworkReachabilityCallBack is called once, but more often than not it's called twice.

I've created a little app to demo this.... https://github.com/kaylanx/ReachabilityTest

And I've filed a bug report with Apple.

kaylanx avatar Sep 22 '15 13:09 kaylanx

The way I've always dealt with this is to use Rechability as the input to a state machine.

That is Reachability changes trigger changes to the state machine, the output of which actually tells your app what to do. e.g. multiple reachability changes to the same state only trigger one output from the state machine.

I've considered releasing the code as an additional layer on top of the base Reachability - When I get some time I'll try and clean it up and do that.

tonymillion avatar Sep 22 '15 14:09 tonymillion

:+1: for that (hoping time comes to you easier than most of us).

scottcc avatar Sep 22 '15 15:09 scottcc

@tonymillion Could you release the state machine as-is? I am running into this problem and wouldn't mind doing cleanup work on it while I have the interest and the time.

Stunner avatar Jul 17 '19 01:07 Stunner