Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let reachability = Reachability.reachabilityForInternetConnection()
- reachability!.whenReachable = { reachability in
- if reachability.isReachableViaWiFi() {
- let alertController = UIAlertController(title: "Alert", message: "Reachable via WiFi", preferredStyle: .Alert)
- let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
- alertController.addAction(defaultAction)
- self.presentViewController(alertController, animated: true, completion: nil)
- }
- else {
- let alertController = UIAlertController(title: "Alert", message: "Reachable via Cellular", preferredStyle: .Alert)
- let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
- alertController.addAction(defaultAction)
- self.presentViewController(alertController, animated: true, completion: nil)
- }
- }
- reachability!.whenUnreachable = { reachability in
- let alertController = UIAlertController(title: "Alert", message: "Please connect to internet", preferredStyle: .Alert)
- let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
- alertController.addAction(defaultAction)
- self.presentViewController(alertController, animated: true, completion: nil)
- }
- reachability!.startNotifier()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement