iOS Reachability check for WiFi fails with personal hotspot - ios

In my app I am using Apple's Reachability sample to check for a WiFi connection (reachabilityForLocalWiFi). If there is no connection a view is shown pretty much like in the App Store app when you have no connection.
This works quite well, but one user now reported problems when using the personal hotspot feature of iOS:
When I use WiFi Personal Hotspot I get the No WiFi message, even though my PC is connected to it.
Does anyone know why this is and how I can fix it? My main problem is that my provider doesn't allow the hotspot feature, so I am not able to test things...

Related

iOS app cannot connect to server over LTE network on iOS 14.7.1

Since last week one user of an app of mine is reporting that the app cannot reach the server on a cellular network. His phone is running iOS 14.7.1 and he has an LTE network connection. The app works perfectly on wifi and I have not had any reports of other users not being able to use the app on cellular networks.
First I thought it was a network detection issue (reachability not being able to see the cellular network), but when I ignore the network detection and simply make the HTTPS request, it does not connect. There is no response from the server. The weird thing is that this is an app with a Google map. The map loads, but the location markers that come from my server are not loaded.
I cannot think of any reason why this is happening and as my testing options are very limited (only this one user is reporting it, I cannot replicate myself), I am kind of lost as to what causes the issue, let alone how to fix it. Are there any settings that I should be aware of for connections over LTE networks to work? Have any new settings been introduced in iOS 14.7 that might affect this? Should the user make any changes on his phone to allow my app to use the cellular network?
I am using a very standard URLSession datatask with an URLRequest to make the call (which works without any issue over wifi).

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 disable wifi assist without user interaction

I have couple of URLs that has to be called(programatically) through wifi not with mobile data.
As WIFI ASSIST is on , whenever the wifi is weak ,packets get transferred through Mobile data.
I would like to stop this from happening.
As far as I have researched, there is no API to toggle wifi assist switch on and off programatically
I can find if the user has mobile data and wifi on with the help of Reachability Class I believe and I can alert the user to keep wifi assist off but this is a very bad user experience.
so I decided to look if its possible to be done with the help of iOS mobile configuration file.
But I couldn't find any keys related with wifi-assist in Apple configuration profile reference.
so I am wondering , is it possible to force wifi to be used for certain URLs.
I remember this is possible with VPN ON DEMAND we can have certain domains to be accessed via VPN.
I am wondering if same is possible for wifi as well through configuration profile
Any suggestions are welcome.
As others have mentioned, there is no way to do manipulate this setting programmatically in iOS. This is not really what you are asking, as you seem to already know the answer to this is "No".
You are asking about the configuration profile, so I am assuming these are managed devices. Unfortunately, there is no configuration profile payload I am aware of that forces the managed devices to disable Wi-Fi Assist.
Your intent, however, is a bit different than what is being asked, I believe. I think you basically have an app that communicates with a resource that is only accessible via the Wi-Fi network (likely a corporate Wi-Fi network). If the app tries to connect to the resource while on cellular, it will not be able to connect. In some cases, when the Wi-Fi signal is weak, the device tries to be helpful and switches to cellular, causing issues with the app. If we could figure out a way to force iOS to not take advantage of Wi-Fi Assist when your app is running, you would be in good shape.
If you can install this app as a managed app, there is a way to identify that the app should only be allowed to run on a Wi-Fi connection. Setting the network usage rules AllowCellularData to false should do this (see this for more details). The thing I am not sure of with this solution, is whether this simply causes the connections to fail when Wi-Fi Assist is on and active, or if it makes iOS prefer to not use Wi-Fi assist when the app is running because it cannot connect over cellular. So I think you can tell an app to only connect over WiFi, but it doesn't really give you a better solution to your user experience problem. The only think it really buys you is that your app connection won't ever try to connect when connected to cellular. There is a chance, however, if you change this value to false for your app bundle ID, it will prevent Wi-Fi Assist from enabling when your app is running. I don't have access to MDM to try it out, but you could test and see.
Ultimately, given that this is probably a corporate device situation, I think you are going to have to address this through user training. The good news is that this is a one-time step. Sure, users may have slight degradation of network performance when Wi-Fi signal is weak but cell signal is strong. This does not matter as much if these are corporate devices where the corporate apps will mostly work only on the company's Wi-Fi network.
Another solution is what you mentioned, basically using on-demand VPN to provide a connection to the internal resources. This is additional infrastructure work, and you already mentioned it, so I'm not sure if it is even an option.
Obviously, the other solution would be to expose the network resources through your firewall, which could allow you to access it over cellular. I'm suspecting this is not possible due to security constraints.
Unfortunately, there are not a lot of good options in this space. However, have hope that there is some way to do it, as Sonos appears to have done something to
allow their app to avoid switching to WiFi Assist while streaming to a local network resource: https://sonos.custhelp.com/app/answers/detail/a_id/4257/~/wi-fi-assist-and-sonos
I wonder if you could have your app open a streaming audio connection to a fixed local network resource, which would cause it to use Wi-Fi. It's a pretty crazy hack, but with a low enough bitrate audio file streaming, it might do what you need while not eating up too much of the network throughput.
Per Apple's notes on Wi-Fi Assist:
Wi-Fi Assist won't automatically switch to cellular if you're data
roaming.
Wi-Fi Assist only works when you have apps running in the
foreground and doesn't activate with background downloading of
content.
Wi-Fi Assist doesn’t activate with some third-party apps
that stream audio or video, or download attachments, like an email
app, as they might use large amounts of data.
Of course the other possible solution that you could consider is improving your Wi-Fi coverage to that the signal doesn't get bad enough for Wi-Fi Assist to be needed. I know this may not be feasible, but wanted to put it out there.
Good luck with this!
There is no public API that allows you to enable/disable "Wi-Fi Assist", and even if you find a way to do it your app will be rejected.
No you can not enable or disable WiFi by programmatically and there is no API for this.

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.

How to let user open Wi-Fi when the Wi-Fi is not enable

When user open my app, I want the Wi-Fi is enabled, it can have no connection ,but the Wi-Fi must be enabled. The query should return true when WiFi is enabled and device is not connected to any network.
Well there is no official support by Apple for this. There however is some trick to get the required result but there are changes of your app being rejected.
Have a look at this unofficial trick:
http://www.enigmaticape.com/blog/determine-wifi-enabled-ios-one-weird-trick
To answer your second question i.e. If wifi is enabled, you can find out if internet is accessible of not using this: iOS Detect 3G or WiFi

Resources