Is it possible, without including an exhaustive list of models in the code, to determine if an iOS device includes a cellular radio?
I am working on adding a check for host reachability to an app, and I'd like the failure message to be appropriate for the device. For example:
A network connection is not available. Please join a Wi-Fi network or move to a location with better cellular reception.
This is fine for iPhone and iPad 3G, but it's amateur for an iPod touch or iPad without 3G. For those devices, I'd like to remove mention of cellular service.
I don't want to create an array in code of every iOS device that Apple has shipped that has a cellular radio.
There doesn't seem to be a way. Erica Sadun has an interesting UIDevice-hardware extension project on github but it can't determine whether there is cellular radio either.
The best you can do is use the Apple provided sample project for Reachability.
http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html
It has three states of the network status:
typedef enum {
NotReachable = 0,
ReachableViaWiFi,
ReachableViaWWAN
} NetworkStatus;
If the ReachableViaWiFi state is returned, don't mention cellular service.
This will be an improvement because even with a cellular radio you might in a wifi only location.
Related
Is there a way may be using private APIs to obtain the complete list of available Cellular networks and assign one manually from my application itself.
Any help is appreciated
No.
Apple is very protective of that kind of thing - an app can't manually assign either a cellular or wireless network for the device to connect to. There is a special chip in the device that handles cellular connections, and only the user can control WiFi connections.
In my iOS app, I want to detect all available wifi networks and then choose one network form the list and connect to it. The goal is to not open the Settings built in app to connect to a wifi, but to do it all in my app.
First, is this possible? If possible, please point me to what framework(s) and methods to use.
I have looked at the Reachability example, but that doesn't work for me because, I think, all it does is monitor the network state of the device.
I also looked at the Captive Network Support framework, and used the CNCopySupportedInterfaces function:
CFArrayRef allWifiNetworks = CNCopySupportedInterfaces();
NSLog(#"%#", allWifiNetworks);
but all I am seeing is the current wifi network that the device is connected to.
Thanks
I'm pretty sure you can't do this, at least not if you want to be able to publish on the App Store.
I'm working on test automation for an app. I'm looking for a way to automate connectivity tests. For that I need to be able to toggle 3G and wifi. I've been going through the private api headers but I haven't found a method that would scream 'I do that!'.
Can anyone point me in the right direction, please?
I can't see this being possible. The iPhone 4 has a setting for 3g on or off in iOS 5, but the iPhone 4s doesn't. If it was possible to turn off 3g in the iPhone 4s I think Apple would have retained that ability in iOS 5.
I assume you've seen the reachability sample code
Thinking about this laterally, iOS connects to known WiFi hotspots when available - so you don't necessarily have to run this on the phone. You could just toggle your WiFi hotspot which you're connecting to on/off, and iOS should automatically switch (as long as any other known WiFi access points aren't in range) to 3G and WiFi respectively.
I am testing the Reachability api, but my physical device only has WiFi access, as I don't have a phone contract. My code needs to distinguish between being connected to 3G/2G or WiFi. Is it possible to simulate a 3G connection on the iPhone simulator?
Clarifications: I am using Snow Leopard. Limiting the bandwidth is not what I need. I need for the actual interface to be identified as the 3G or 2G radio, as opposed to WiFi.
If you are using Lion try the Network Link Conditioner
Nowdays there is a part in Preferences on the device (when registered as a developer device) where a "Network Link Conditioner" is available.
You might also like Speed Limit.
Edit: I'm not sure if this will work as an identifier for 3g though. I'll update my answer after I do some tests (I'm working on exactly the same thing right now!)
I dont think that it is a build-in-functionality in iphone-simulator. But I test it sometimes on my device with wifi (and 3g) disabled.
If you dont have an iPhone but sth. similar (Android for instance) then just enable tethering on your device and use the tethered internet-connection. Then your iPhone-Simulator only gets slow speed ;)
edit: another idea is to limit the bandwidth of your mac. I found this tool online (have not tested it) which should be able to limit network-traffic (to your local router/modem)
I'm in the process of getting hardware for an iPhone prototype, and I'm wondering if it's possible to access bluetooth (ExternalAccessory, Bonjour or GameKit) exposed by development box (eg. a macbook) using the SDK's simulator as of the latest version (3.1.3 at the time of writing)
Before I get any answers on the subject, I accept that I will need an iPhone for the actual development - this is simply a prototype.
I'm not sure I understand your question entirely.
I can state that in iOS (as of May 2011) the only access you have to bonjour is through the Gamekit functionality. That functionality is fairly robust, but (for instance) you will not be able to create a BT based bonjour service that other non-iOS BT enabled devices can find.
On the simulator, even if the underlying device HAS bluetooth capabilities, you will NOT be able to perform "real" bluetooth operations. Instead the simulator will simulate some capabilities, and ignore others. You really do need multiple devices to load your code onto and run, in order to test out BT code.
Bluetooth connectivity is inaccessible using the Simulator. If WiFi is good enough for you, that works with Bonjour and GameKit on the Simulator as well. Otherwise, just like for the accelerometer and several other components of the device, you will need an actual device.