reachability

How do I receive notifications that the connection has changed type (3G, Edge, Wifi, GPRS)

淺唱寂寞╮ 提交于 2019-11-28 10:49:20
问题 Is there a way to discover whether the current connection is 3G, Edge or WiFi, and receive a notification of this? Or just a way do discover whether the connection is WiFi? 回答1: You should use Apple's Reachability class http://developer.apple.com/library/ios/#samplecode/Reachability/Listings/Classes_Reachability_h.html after implementation you can use this in the delegate: - (void) configureTextField: (Reachability*) curReach { NetworkStatus netStatus = [curReach currentReachabilityStatus];

iOS network reachability - doesn't seem to be working

…衆ロ難τιáo~ 提交于 2019-11-28 10:18:27
I'm following How to check for an active Internet connection on iOS or OSX? and http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html to test for connectivity, but am running into some pretty basic issues. For example, I'm running a .NET API off of another machine and then trying to connect to it via my mac mini. 1) When IIS is running, everything is working like it should, I was excited that I got this working! 2) I can shut off IIS completely (obviously, host is unreachable) but my reachabilityWithHostName is still reporting that the host is reachable. Any

Using 'stringWithString:' with a literal is redundant [duplicate]

别等时光非礼了梦想. 提交于 2019-11-28 08:31:50
问题 This question already has an answer here: Obj-C: [NSString stringWithString:@“string”] vs. @“string” 3 answers i used this code in reachability class that is in ios6 switch (status) { case kNotReachable: statusString = [NSString stringWithString: @"Not Reachable"]; break; case kReachableViaWWAN: statusString = [NSString stringWithString: @"Reachable via WWAN"]; break; case kReachableViaWiFi: statusString = [NSString stringWithString: @"Reachable via WiFi"]; break; } but the following error is

Using Apple's Reachability to check remote server reachability in Swift

北城余情 提交于 2019-11-28 07:34:33
I'm developing an iOS application written in Swift that communicates with a HTTP server on the local network, and I'm using Apple's Reachability class to determine wether the remote machine running the HTTP server is online or not. Here's the code: ... let RemoteHost: String = "192.168.178.130" var RemoteReachability: Reachability! = nil var RemoteIsReachable: Bool = false init() { super.init() self.RemoteReachability = Reachability(hostName: self.RemoteHost) NSNotificationCenter.defaultCenter().addObserver(self, selector: "reachabilityChanged:", name: kReachabilityChangedNotification, object:

iPhone SDK reachabilityWithAddress issue

若如初见. 提交于 2019-11-28 05:06:09
问题 I need to check connectivity with IP address only. I'm trying to do it with Apple Reachability class, using reachabilityWithAddress option. And my problem is I can put any IP address in callAddress.sin_addr.s_addr field and statusText always will be "reachble". How can I do to exactly check connectivity to IP address? -(BOOL)reachabilityTest { struct sockaddr_in callAddress; callAddress.sin_len = sizeof(callAddress); callAddress.sin_family = AF_INET; callAddress.sin_port = htons(24);

Using Reachability for Internet *or* local WiFi?

眉间皱痕 提交于 2019-11-28 02:56:13
问题 I've searched SO for the answer to this question, and it's not really addressed, at least not to a point where I can make it work. I was originally only checking for Internet reachability, using: self.wwanReach = [Reachability reachabilityWithHostName:@"www.apple.com"]; [wwanReach startNotifer]; I now need to support a local WiFi connection (in the absence of reaching the Internet in general), and when I found +reachabilityForLocalWiFi , I also noticed there was

Are there more sophisticated alternatives to Apples Reachability class?

冷暖自知 提交于 2019-11-28 01:36:24
问题 Apple has created that famous Reachability class but looking at the code I don't trust it much. The formatting and header is messy. Also it provides no help for showing that "You have no internet!" alert. I just want to do: At some point download a XML. When there is no internet, show alert. When internet disconnects while downloading the XML, show alert. In my app the user taps no download button it all happens automatically in the background. That's it. Really. I spent now 3 hours with

How to detect change in network with Reachability?

爱⌒轻易说出口 提交于 2019-11-28 00:23:51
问题 I'm currently checking network connection on viewDidLoad using this: -(BOOL)reachable { ReachabilityDRC *r = [ReachabilityDRC reachabilityWithHostName:@"google.com"]; NetworkStatus internetStatus = [r currentReachabilityStatus]; if(internetStatus == NotReachable) { return NO; } return YES; } But I also want to be notified if there is a change of network, such as wifi dropped, or wifi is back, so I can make changes accordingly. How can I adjust my method to do something like that? 回答1: Another

Should I listen for reachability updates in each UIViewController?

余生长醉 提交于 2019-11-27 16:28:45
问题 I see a lot of Reachability examples where people only display a message when reachability status changes. But recently, I saw in Foursquare app that they display a message every time the user try to make an action requiring an Internet connection. I think this is more robust and a better UX to remind the user he can't do anything without Internet. Mainly because users can switch between apps, do something else and forget he has no connection when he comes back. Also as soon as they get the

Reachability Notification Never Called

为君一笑 提交于 2019-11-27 15:31:32
问题 I am having a hard time using Reachability in my code. I would like to keep it very simple by initiating an observer at launch and then just receiving change notifications. In the following code, the reachabilityChanged method is never called. I’ve tried many iterations but this is the simplest version. It compiles and runs. Please help... ** * * AppDelegate.h code * ** * #import <UIKit/UIKit.h> #ifdef PHONEGAP_FRAMEWORK #import <PhoneGap/PGViewController.h> #import <PhoneGap/PGURLProtocol.h>