iOS enterprise vpn connectivity - ios

In an iOS application if you had to access corporate remote services, through VPN, what would be your pattern to ensure you have connectivity and inform the user if that's not the case:
check that your network and VPN are working (by checking if some host like google.com and some private enterprise host are reachable) and if that's the case then call the remote service?
or call directly the remote service, and if there is a network exception, then check if both a network host and an enterprise host are reachable? (to find-out what's going on and inform the user)
or you would do it differently?

Usual approach:
1)User opens VPN client enables VPN connectivity
2)User uses the app.
Alternative approach:
If you are developing an enterprise application
then you could possibly start and stop VPN connection right from the app using apple's private api.
Advantages of the approach:
So that all the network connections from the app are routed through VPN and user doesn't have to enable VPN connection every time he uses the app.
Reference:
You could find some hot discussions on this topic in the following threads.
Thread 1
Thread 2
Thread 3

Related

How to deal with local network changes (NSLocalNetworkUsageDescription) on iOS 14?

Our application connects to a local WiFi network (using TCPClient) for data communication purposes.
But in iOS 14 the connection fails completely because two processes take place at the same time:
TCP client initialization
Current network permissions
So the connection to the local network is blocked until we reopen the application.
To avoid this, we're doing a hack: Pinging to a local IP address triggers the current network permissions (this is done in the OnActivated() method of AppDelegate).
The connection only works properly if it is connected to that particular network otherwise it fails.
Has anyone faced this issue before? I appreciate any suggestions from the community.

VPN - NEPacketTunnelProvider - background mode

I'm building a simple VPN app.
I got networking entitlements, and I created the app extension.
I've configured the VPN to be "on demand" and active while sleeping.
My question is - What happens when the app is in background mode ?
Should I add more app capabilities, or is it enough ?
(And a following question - while in a background mode, the app extension functions like startTunnelWithOptions(...) are still getting called, Am I right? )
The application which starts the Packet Tunnel Provider is called as container app. Here your application is the container app.
The container app and packet tunnel provider runs in separate process. Container app and the Packet Tunnel provider process communicate through IPC.
Even when your application goes background your packet tunnel provider keeps running and handle your application according to packet tunnel provider(VPNManager) status when moving from background to foreground. You need not add any other capabilities.

Is it possible to build socket connection between 2 iOS devices

Is it possible to build a socket connection between 2 iOS devices connected to the same network (Without net)?
if it's possible .. Is (CocoaAsyncSocket project) useful for me?
I just want to send a message from Device A to Device B which put the app in background .. when Device B receive the message should show notification to return the app to foreground.
It's not for the App Store, so I don't care if Apple would reject the app because of this behavior.
Yes, you can do it, and yes, CocoaAsyncSocket would be useful. If you don't have to worry about the carrier network's firewalls and filters, then you should certainly be able to build a client-server app running on two iOS devices. One opens the server socket to listen, and the other one (the client) connects, via the Wi-Fi network.
Trying searching on Google (e.g. "CocoaAsyncSocket iPhone iOS site:stackoverflow.com") or directly here on Stack Overflow.
Here's somebody who seems to have accomplished this
Another link
And a post from Robbie Hanson himself, referring you to the EchoServer projects in the github repository
EchoServer project
You may have to use a static IP address for the server device (I'm not sure how much control you have over the Wi-Fi network's configuration), or use some other mechanism for letting the two devices discover each other.

Force iOS device app to talk through the local WIFI network

I'm building an application that will run in a museum with a local area wifi network without internet access, for some strange reason I'm not able to fully "join" this network with an iOS device. Enabling internet access on this network solves the problem...
The network should provide only a web server and a DNS server, the access point has a DHCP server, android devices can connect to the network without problems.
When I try to join the network with the device it remains in a "spinning wheel" status, the DHCP server log on the debian server says it has assigned an address to the iOS device, and if I check for the wifi address with an application (like iSys o SBSettings) I see the WIFI DHCP assigned address.
But when my app (or safari) tries to connect to the web server the request is routed through the 3G connection and not completed.
In my app I'm using the standard "Reachability" framework from Apple to check the reachability of a provided host name through the wifi connection and I get 0 on the SCNetworkReachabilityFlags mask....
I'm quite sure the problem is due to the fact iOS (5.1 in my case) tries to check the reachability for some "standard" host in the network, before routing traffic through the WIFI connection.
Anyone knows what an iOS device do to "validate" a WIFI network? I can add hostnames or simple dummy services to the server machine if this can help me connect the device to a LOCAL-only network :)
It seems that iOS doesn't like to join networks without a gateway, also if the network is local you have to setup a correct gateway address.
Setting the gateway as the server itself did the trick and the device started to route TCP/IP over my local area wifi network.

How bonjour works on IOS?

I created an application using bonjour and I am able to send files from one device to another. But the question is: I am not able to discover the devices on the LAN without running both the applications on the device. Do I need to run the application using bonjour to get it detected using bonjour.
Yes you do. Running the application registers the appropriate entries into the iOS multicast DNS service. Once you shut the app down I expect it removes itself from the multicast DNS registry (which it is correct to do, because it is no longer available), so you can't find it from other devices.
EDIT: (Very roughly) Bonjour is multicast DNS. The Bonjour service runs a multicast DNS server. When your application starts up it communicates with the local multicast DNS server and creates a number of entries that identify the service it is making available, the ports it is available on and other relevant attributes. It also registers itself as interested in learning about any other network device that is running the service.
The local multicast DNS server makes announcements that signal to any one else listening on the network that a new service is available. Your app (on a different machine) is notified by the Bonjour service that another client has appeared, and that is more or less how the magic is done. Longer multicast DNS writeups are all around: Google is your friend.

Resources