1

I want to block my app's ui when there is no network connectivity.

I saw this post about checking network connectivity.

Is there a way to register for a listener with callback "onNetworkLost()", "onNetworkAvailable()"? Instead of creating my own periodic task?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Elad Benda
  • 35,076
  • 87
  • 265
  • 471

1 Answers1

1

You can use Reachability class to get notification when network status has changed. Refer https://developer.apple.com/library/ios/samplecode/Reachability/Introduction/Intro.html for documentation as well as sample code on integrating Reachability. It gives you kReachabilityChangedNotification notification which is broadcasted when network status has changed. Once you get the notification you can check whether network is available or not.

You can also refer this How to use reachability class to detect valid internet connection?

Community
  • 1
  • 1
Vishnu gondlekar
  • 3,896
  • 21
  • 35