I have been writing Unit Test and UI Test in my app. I have completed the most part of it. The pending thing is the Network Retry view. This page will be called when there is no internet. Is there any way we can turn off internet access (WiFi) in runtime so that i can execute UI test cases to test this page? In other words, this page will be called in the dashboard if there is no internet. So for going to the dashboard, the app needs internet access(to login, etc). Once it goes to the dashboard, i should be able to turn of internet access from within my test case and then check the Network retry page.
Use Network Link Conditioner to control the internet connection
Related
Many Wi-Fi hotspots these days have a "web login", especially free ones. You know, the ones that redirect any HTTP request to their login form.ios first connect to a wifi network then opens up the login page of the network where we fill our credentials and then it let us access the internet. Now I am creating a ios app that runs when connected to a particular network and instead of opening my browser the app takes user credentials once and automatically login for user and user can access the internet. Now how do I open my app whenever the user connects to the network and instead of opening up the app I would like it to show my app notification with the option of Login or Logout in the notification bar.
In android it appears like this:
You need to register a URL scheme within your app, and then configure your login page to call a certain URL containing the information you need. For example, if your app was called "Foobar", a valid URL might look like foobar://auth?user=jacobking&pass=password123. As I said, you will need to tell iOS that your app is listening for the foobar scheme. When iOS receives this URL, it will ask your app delegate if it can open it which you will answer through canOpenURL.
A detailed explaination and code examples can be found here.
If No Internet connection and I block UI with present one View controller with "Please check your Internet Connection" pop up then Can Apple reject my application for blocking UI?
I don't work at Apple, but I guess if an app requires an internet access to work properly, it is fine to block the UI until the user has an actual internet access.
Think about social network apps, if you just installed Facebook app, you would not be able to login upon first launch if you don't have an internet access.
However, blocking the UI seems a little bit strong and probably bad UX as well. Nevertheless, it should not prevent you from publishing your app to the App Store.
Vibha Singh,
Why block the UI ??? Blocking the UI is probably the worst user experience. Apple might not reject it (not sure as I never tried it before but certainly people will not appreciate it)
In case you have an app which you dont want to work when there is no internet then consider designing a screen which you will load which will have text saying "No internet connection try connecting your device to internet something like that"
Facebook, Twitter all the main stream app's follows the same approach rather then blocking UI
So here is the question
Many times you start your app and and your first API request fails and you realize that even though you're connected through internet You need to login in to Your office' or home network's firewall or sonicwall and login there
So you need to open safari and open your sonicwall page and login there and come back to our app and start it again.
I want my app to detect the same and show the the redirected html page in UIWebView and once the authintication finishes i want to execute the original request withing my app
My question is
1> Is it possible ?
2> If yes how can i achieve it ?
I would suggest using the same captive portal probe URLs that Apple uses in iOS Safari, for maximum compatibility. If those URLs return 200, you shouldn't be behind a (good) captive portal, assuming I'm remembering the details correctly.
You can beef that up further by using reachability APIs to detect network changes, and probing that URL, along with Google's generate_204 URL. And in some places, you'll find Google blocked (China, IIRC), in which case you might also consider a URL with a known, predictable, machine-validateable value, such as Apple's root certificate URL. :-)
When the user signs in, you should get another reachability change event, at which point at least one of your captive portal probes will succeed, and you can reissue any outstanding requests.
I develop a well-looking professionally designed application, which loads events for some clubs at startup (it has more functionality, but all require network connection).
If there's no internet access, app shows "Error: No network access" message with OK button. It exits when user presses this button.
Will it be accepted in App Store? If no, what should I change?
Thanks! :)
This is an opinion question, but my experiences suggest:
It's OK that your app requires network access to provide meaningful content.
Do NOT forcibly terminate (exit) your app in this case, but instead show a helpful message, and keep polling the network status (ie use something like Reachability). If and when the network connectivity comes back, remove the message and proceed.
Bonus points: If you can cache data from when there is a connection, then you can run the app anyway showing the most recent data you have. This is generally preferable as a user experience to simply blocking access to the UI if you can't get to the internet.
Do not exit the application.
If your app work only if network is available, that's okay. But if network is not there, it would be better if you show an empty view with proper message (That for this app, network is needed or something like that. Add some error images or graphics it'll improve the user experience also). Don't forcefully close the app, it can be consider as a crash(Apple will reject your app).
I need to test various alerts that comes when network disconnects at various points of test flows. So I need to disconnect iPad/simulator from network. Is there any way where we can toggle network settings during tests execution time from within the tests ?
I have searched and found it is not possible : Is it possible to disable the network in iOS Simulator?
But, the response here is old , wondering do we have some approach now ?
Using function performTaskWithPathArgumentsTimeout on UIAHost you can run any program on your computer (if you know the absolute path).
If you can write a program or script (e.g. using osascript) which will turn your internet connection off, then it's possible.
I am actually using this function to open a web page in the simulator which redirects to a link handled by my application, thus testing the behavior when the application is opened from the browser.