I’m trying to implement Reachability in my app. I have it in applicationDidFinishLaunching. If my connection is really bad and I launch the app, Reachability takes forever and often crashes the app with an The application failed to launch in time error message.
So instead, I tried putting the call to Reachability in a background thread. But when I do this, I no longer receive the Reachability notifications.
Where should I be calling Reachability?
Edit:
I added TonyMillions’ Reachability code per the suggestion below, but I’m still getting the same application failed to load in time error when in very bad network conditions. To reproduce what I’m seeing, go to Settings.app -> Developer -> Network Link Conditioner, turn it on and set it to 100% loss.
Does your app still load in that condition?
TonyMillion helped me solve this over on GitHub.
If you’re using his Reachability replacement, all you have to do is wrap the
startNotifiercall like so:The app won’t fail to launch in bad network conditions, and you’ll still get notifications on the main thread.