We recently ran into an epic bug at work getting an NSURLErrorDomain error from Unity. I had a hard time searching Google for a cause of the error so I am providing a blog post on it here hoping that it will help others in the future.
Use Case: We had several users who could load our app and other apps just fine on their iOS devices while using Wifi connected internet. However once they switched to Cellular data, our app would not connect while other apps would work just fine. In fact under Safari in the iOS device we could access our destination url’s just fine.
This particular app was built in Unity and was spitting back a “NSURLErrorDomain” with a message similar to “The internet connection appears to be offline”. Unity was hiding the exact NSURLErrorDomain error code but we were pretty confident it was a “-1009” error which is the “NSURLErrorNotConnectedToInternet”
We did all kinds of things. We checked DNS settings, we investigated the Reachability API, we updated iOS on the device, we updated/downgraded the app, etc. Nothing seemed to bear fruit.
As it turns out the error stems from a bug in the iOS software that was released into the wild and then later patched. The bug report was as follows:
“After upgrading your iPhone / iPad to iOS 9, it’s impossible to enable (or disable) the mobile data (cellular data in the US) switch. This means you cannot connect or access iOS apps over the 2G, 3G, 4G LTE network.”
What happened was the user installed the app while being effected with this bug. The app (our app) was then installed with Cellular data turned off. We had to instruct the user to go into their device and manually switch cellular data back on for our app on their device. This immediately solved the issue.
We currently have no intelligent way to tell that a user has been exposed to this bug because we do not know whether or not a user has flipped their cellular data off for our app. All we know is whether or not we have an internet connection. If you have ideas on how to detect this scenario we would love to hear about it in the comments.