iOS: how do I know if I'm still connected to oprators's cellular network - ios

My iPhone is connected to cellular network and my own WiFi. If I go to the basement I'm still connected to wifi, by cellular connection goes down. How can I know that the cellular connection is active or not?

You need "Reachability". Apple have provided it since the early days of the SDK, there is a link to a version by Tony Miller in this answer and it is also part of the highly recommended AFNetworking (another relevant answer). It will tell you whether you have any connection and what kind it is.

Related

Connecting 30 iPads

I am currently programming an app for my school.
During the lesson the teacher needs to send and stream data to the students. There is a case in which one of the students streams the data to everyone else. The teacher uses an iPad and every student uses one.
My question is: How could this be realized without a local network or an internet connection?
Two solutions came to my mind when thinking about it:
Multipeer Connectivity. The problem with this solution is the limit to 8 devices. I have read that you can open multiple sessions at a time but I am worried that 30 devices are too many.
Having the teacher-iPad open a hotspot which the other iPads join. This hotspot will be used as a local network to communicate (as far as I know, this works on Minecraft PE). This would only be an option if the hotspot and it's password could be configured by the app, otherwise it would be too complicated to use in a lesson.
Thanks a lot for reading my text. I hope that you can help me.
Your devices need to transmit using wifi or bluetooth. I have a recollection that MCSession stopped being able to use bluetooth a few years ago. MCSession may work only if all devices are on the same wifi network.
Probably you can first use Multipeer Connectivity to setup the network, then use a hotspot or other solution afterward.
For example, using Multipeer Connectivity to send the wifi name and password to other devices. Once a device receives the setup information, you can disconnect it so that other devices can get connected.

How can you tell if someone is cutting you off from a wifi connection on your laptop or is it just a weak wifi signal?

I need your knowledge and/or opinions about this since I'm concerned if someone is doing it, or if the WiFi signal isn't strong.
My laptop is connected to WiFi that I do not own (they know that it is connected and they know it's me), and I am just watching YouTube videos, then after like 7 minutes I get disconnected from WiFi. When that happens, I just restart my laptop and it auto-connects to the WiFi. The fastest that I got disconnected is when the moment I opened my Google Chrome browser.
My laptop is near to the modem/router. This is happening like when I feel like it's coming and it's kinda fast. Here are my questions about this:
I use an add-on VPN for my Google Chrome browser, does this affect my connection?
They use an Apple iPhone. Could it be that they're disconnecting it from the phone?
Does a USB WiFi adapter help, and is there a USB WiFi adapter without needing to put in WiFi info?
Is there any software that can help me detect if someone is cutting me off from the WiFi connection?
Maybe there's an app they use that can disconnect me from WiFi?
What are my defense options?
Maybe it is because of the brand of the laptop?
I've burnt out of questions for now, but there must be more. Please help.
I also just saw that my Internet connection got disconnected then reconnected again in just like 1 or 2 seconds.
It doesn't sound like they are 'disconnecting' you. To me, I would first check the DHCP settings within the WiFi router, but if you don't own it, that might not be possible.
It sounds like you are unable to maintain a valid IP address. I think this is happening due to the fact that when you restart your machine, and request a new IP, it seems to work for a short period of time. It's a tough problem to troubleshoot without more information though.

Wifi assist on iOS not working

I have next case:
Wifi assist enabled
I connected my iphone to WIFI without inet
connection
I enabled Cellular Data(mobile data)
My app cant send requests. Network is unreachable.
I try open some page with safary, but "server cannot be found"
I thougth if I enable assist, ios should switch between GSM and Wifi, am I right?
Any idias or advice
I have had this problem too for a long time. Talked to Apple about it online but their solution was not to forward this to their developers for a bug fix, but to install the next update and see if this helps. So Apple's solution is to not do anything. Thanks for that.
The issue seems to be that the wifi assist only works on wifi signal strength and not on the ability to actually meaningfully transfer data to load even the most fundamental of website homepages. There is only one solution at the moment and that is that when you encounter these wifi networks that load nothing, that you have to go into your wifi option in settings and manually 'Forget this network'.
Not ideal but that's the only solution I have that seems to work.

How to select specific network interface for NSURLSession connections?

I’m not talking about Reachability.
What I’m talking about is figuring out how to create a network connection from an iOS device across the cellular interface.
Why? Because I have conditions where the device connects to a WiFi access point so it chooses WiFi… but that access point is not internet connected and goes nowhere. I have data which I must make every effort to deliver and it some cases it’s getting lost in the WiFi gateway to purgatory. In both cases of using Reachability and relying on MPTCP, Apple has already given priority to WiFi in the stack.
I know NSURLSessionConfiguration can set allowsCellularAccess to allow cellular access — I’m looking to require cellular for the routing.
Even at the CFNetwork level I’m looking at kCFStreamPropertyConnectionIsCellular for status, kCFStreamPropertyNoCellular to disable cellular.
I can’t find anyway to give preference to the cellular radio. I realize Apple has gone to great lengths to prefer WiFi and I’m going against that — which is why I’m having such difficulty finding an answer to this.
I'd like to keep this up in the Cocoa level, but not opposed to going into Foundation or deeper levels. I would like to avoid trying to parse an interface table (if it's even accessible) to figure out which is the cellular interface.
Has anyone successfully created a network connection across the cellular link despite WiFi appearing to be present?
Is some configuration of Multipath TCP the answer here?
To bind to a particular interface, as far as I'm aware, you'd have to drop all the way down to the raw socket level, and there's no way to provide a custom socket for NSURLSession purposes, so you'd basically be rewriting it from scratch. You should file a bug asking for support for binding an NSURLSession to a source IP.
The behavior you're experiencing is a known problem with iOS and disconnected networks. iOS 9 and later do a better job, but even then, they can be highly problematic; the devices sometimes refuse to talk to the Wi-Fi network, and sometimes refuse to talk to the cellular network. Specifically, it seems to fail spectacularly if either signal is weak. Just this morning, I actually had to force my iPhone (iOS 10) to talk to a disconnected Wi-Fi network by putting it in Airplane mode and enabling only Wi-Fi.
I'm told that you can fix this by configuring the network's DHCP server to not provide a router advertisement; that said, every time I've tried that, the iOS device would just keep asking for an offer repeatedly. Maybe that bug got fixed at some point. If so, it might be worth a shot, but don't expect it to work in older versions of iOS.
Failing that, assuming you don't need to support web browsers in iOS 3 and earlier, you might try eliminating the DHCP server on that Wi-Fi network entirely, and just rely on DNS service discovery with zero-conf IPs. That way, the device won't see a router, and it won't try to send data out that interface except to those link-local IPs.
If that isn't possible for some reason, ordinarily I would suggest using a customized copy of libcurl, except that I doubt this will work in your case, because POSIX networking doesn't wake the cellular hardware.
In iOS 12 and later you can use the Network Framework. Sample code is here.

Are Wi-Fi Direct and Wi-Fi P2P the same?

Maybe this is a stupid question but..
Are Wi-Fi Direct and Wi-Fi P2P the same thing?
And I mean, the EXACTLY same thing?
I'm getting really confused with this two.
Wifi Direct is a technology for peer to peer connections and is very different from wifi. Wi-Fi Direct, initially called Wi-Fi P2P, is a Wi-Fi standard enabling devices to easily connect with each other without requiring a wireless access point.It is usable for everything from internet browsing to file transfer
Wifi Direct is not same as wifi . On Jelly Bean and above, when you try to use the WifiP2pManager API, WiFi-Direct is automatically enabled (as long as WiFi is on). Wifi can be switched on by calling:
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); wifiManager.setWifiEnabled(true);
For ICS refer to this Can I turn on WiFi-Direct from code? on Android API-14 (ICS)
This is the main reason to get confused between the two.

Resources