Questions tagged [reachability]

Reachability is an iOS sample application which demonstrates how to use the SystemConfiguration framework to monitor the network state of an iPhone or iPod touch. In particular, it demonstrates how to know when IP can be routed and when traffic will be routed through a Wireless Wide Area Network (WWAN) interface such as EDGE or 3G.

Reachability is an iOS sample application which demonstrates how to use the SystemConfiguration framework to monitor the network state of an iPhone or iPod touch. In particular, it demonstrates how to know when IP can be routed and when traffic will be routed through a Wireless Wide Area Network (WWAN) interface such as EDGE or 3G.

856 questions
1403
votes
39 answers

How can I check for an active Internet connection on iOS or macOS?

I would like to check to see if I have an Internet connection on iOS using the Cocoa Touch libraries or on macOS using the Cocoa libraries. I came up with a way to do this using an NSURL. The way I did it seems a bit unreliable (because even Google…
Brock Woolf
  • 46,656
  • 50
  • 121
  • 144
313
votes
31 answers

Check for internet connection with Swift

When I try to check for an internet connection on my iPhone I get a bunch of errors. Can anyone help me to fix this? The code: import Foundation import SystemConfiguration public class Reachability { class func isConnectedToNetwork() -> Bool { …
b3rge
  • 4,959
  • 7
  • 23
  • 24
151
votes
16 answers

Easiest way to detect Internet connection on iOS?

I know this question will appear to be a dupe of many others, however, I don't feel the simple case is well explained here. Coming from an Android and BlackBerry background, making requests through HTTPUrlConnection instantly fail if there is no…
RealCasually
  • 3,593
  • 3
  • 27
  • 34
110
votes
11 answers

iOS Detect 3G or WiFi

I am not sure if this is possible, but I have this scenario. I have a website displayed in my UIWebView which has the link set in a UISegmentedController. They website can detect if you are on wifi or on the 3g network. Now the segmented controller…
jwknz
  • 6,598
  • 16
  • 72
  • 115
103
votes
8 answers

How to use SCNetworkReachability in Swift

I'm trying to convert this code snippet to Swift. I'm struggling on getting off the ground due to some difficulties. - (BOOL) connectedToNetwork { // Create zero addy struct sockaddr_in zeroAddress; bzero(&zeroAddress,…
Isuru
  • 30,617
  • 60
  • 187
  • 303
44
votes
11 answers

Detecting Network Connectivity Changes using Reachability, NSNotification and Network Link Conditioner in Swift

From iOS 12 you simply use NWPathMonitor which is a line of code (example). For historic purposes: I'm trying to integrate network connectivity detection into my app, however it seems that somewhere along the line I have made a mistake as my…
iamktothed
  • 1,398
  • 2
  • 14
  • 22
43
votes
3 answers

Reachability Guide for iOS

Has anyone found a halfway decent guide to implementing Reachability on iOS?
esqew
  • 42,425
  • 27
  • 92
  • 132
41
votes
9 answers

How to check internet connection in alamofire?

I am using below code for making HTTP request in server.Now I want to know whether it is connected to internet or not. Below is my code let request = Alamofire.request(completeURL(domainName: path), method: method, parameters: parameters,…
TechChain
  • 8,404
  • 29
  • 103
  • 228
39
votes
5 answers

iPhone reachability checking

I've found several examples of code to do what I want (check for reachability), but none of it seems to be exact enough to be of use to me. I can't figure out why this doesn't want to play nice. I have the reachability.h/m in my project, I'm…
Sneakyness
  • 5,305
  • 4
  • 33
  • 39
36
votes
3 answers

How to use iOS Reachability

I'm developing an iPhone app that uses the network. The iPhone communicate with my server via HTTP request and should work on WiFi and 3G. I currently use NSURLConnection initWithRequest to send async requests to my server and get responses (but I…
Eyal
  • 10,777
  • 18
  • 78
  • 130
32
votes
8 answers

Need Reachability version for ARC in iOS5

Using Apple's Reachability code in iOS5 I get a bunch of compilation errors as shown below. Any ideas on what is happening here? I'm using ARC so I have edited the standard code slightly to remove autorelease/retain and the…
millport
  • 2,411
  • 5
  • 23
  • 19
32
votes
11 answers

How to use NetworkReachabilityManager in Alamofire

I want functionality similar to AFNetworking in Objective-C with Alamofire NetworkReachabilityManager in Swift: //Reachability detection [[AFNetworkReachabilityManager sharedManager] startMonitoring]; [[AFNetworkReachabilityManager sharedManager]…
MuraliMohan
  • 1,063
  • 1
  • 11
  • 30
28
votes
2 answers

Why is Promise not considered in reachability analysis?

Assume we have this function: function returnNever(): never { throw new Error(); } When creating an IIFE, the code that comes after it becomes marked as unreachable: (async () => { let b: string; let a0 = returnNever(); b = ""; //…
nikeee
  • 10,248
  • 7
  • 40
  • 66
24
votes
2 answers

How to get Reachability Notifications in iOS in Background when dropping Wi-Fi network?

I'm using Reachability successfully to determine the status of the network, and to be notified of changes (e.g. Reachability Guide for iOS 4). My question isn't how to get Reachability up and running, but rather the following. My AppDelegate…
Tim Arnold
  • 8,359
  • 8
  • 44
  • 67
20
votes
1 answer

git reflog expire and git fsck --unreachable

Disclaimer: this question is purely informational and does not represent an actual problem I'm experiencing. I'm just trying to figure out stuff for the sake of it (because I love figuring stuff out, and I know you do too). So I was playing with…
Geoffrey Bachelet
  • 4,047
  • 2
  • 21
  • 17
1
2 3
56 57