how to turn on vpn in ios app ? ( public api ) - ios

there are many kind of app in appstore that use vpn on demand.
some application like hotspotshield when you open the app, it can turn vpn on even if vpn on demand is off.
is there any public api for turning vpn on in app, like hotspotshield ?

even astrill is an app available for ios (iPhone VPN connect app).. it provides a toggle to switch vpn on and off from the app directly... so my guess is it used some third party api..
right now.. there is no public api available to toggle vpn from an app..
urlscheme could have been used to atleast open vpn setting from ur app .. but even that was deprecated.. so no chance for now

Now it's possible, but only with IPSec and IKEv2 protocols. See this great example https://github.com/lexrus/VPNOn

Related

Does Apple permit the usage of socket for communication between two iOS apps?

So basically I have two iOS apps installed on the same device, and they need to communicate by sending data to each other. I don't want to use URL scheme or Universal links as these two would open the other app in UI instead of sending message to each other in the background. Currently I have a solution of using a unix socket connection by binding one app to a specific port and have another app connect to it. This works fine but I am just wondering if Apple would allow the usage of this.
Note that these two iOS apps do not come from the same developer so anything else that relies on App Group would not work in this case..
Would Apple allow using a socket in this case?
Edit: One of the app is valid to run in background, so background execution is not a problem
No, this is not possible simply because the application will lose network connectivity when it goes into background mode. I invite you to check the following Apple Developer Documentation page related to iOS app background modes:
Background Execution
As you can find on the page, the operating system suspend the app when it moves to background and will then cut several resources including network access.
There are however some exceptions to the rule, which are voice ip apps. These must declare the voip background mode in the plist file to be allowed to keep network streams open in the background.
This question comes a lot on iOS or Android and unfortunately the answer so far is no, we can do tcp client / server communication between apps.
It is totally doable as long as one of your apps has permissions to run on the background. Such example is music apps. Spotify does the same thing with their “app-remote” SDK.

Implementing VPN with L2TP protocol in iOS app

In iOS settings, there are options to create a VPN configuration using IPSec, IKEv2, and L2TP. Using the NetworkExtension framework from Apple there's an option to create VPN using IPSec and IKEv2 protocols only. They do work but problem is that I need to create a connection via L2TP since that's only supported by the company's firewall.
There's a question iOS app with custom VPN connect from 2014 and it's answered with:
If you want to connect programmatically in ios 8 you can use only IPSec or IKEv2 protocols. L2TP and PPTP protocols are private for apple. It is not possible to use L2TP and PPTP APIs in your applications. Only Apple is currently using these APIs.
Is there any way to create a L2TP VPN connection from an iOS application (Swift)?
The Personal VPN feature that allows using built-in protocols doesn't support unencrypted protocols, presumably for security reasons:
Personal VPN only supports recommended VPN protocols; it doesn’t support legacy VPN protocols, like PPTP and L2TP.
However, that's not the only way to implement a VPN app. You can also create a Packet Tunnel Provider to tunnel layer 3 packets yourself, or an App Proxy Provider for TCP and UDP connections. A packet tunnel provider would allow using your own L2TP implementation.
This might be solving the wrong problem, though. If this is for a specific company, why not use MDM instead of a custom app? MDM does support L2TP.
It is not possible to create a L2TP VPN connection from an iOS application. Only Apple is currently using the L2TP and PPTP APIs.
Is it possible that the company this is for has some sort of internal framework or package you can use for their VPN authentication within your app?
You can make use of every proxy app available on Android playstore. Basically youre iOS device will make use of the hostpot from android phone.
Remember youre android phone must be connected to L2TP VPN.
Every proxy will put all the connection of VPN shared to iOS device.
iOS device in settings we need to add ip and port. You will now be connected to VPN on iOS.
You can try hosting an l2tp server on your mac and connect another device remotely to the server using the settings->network->vpn->l2tp and provide the settings. I haven't tried it personally. On the iPhone General->VPN Management->L2tp can be used.

Is there a way to Connect with a Wi-Fi Modem via my iOS app without using Settings Page?

I want to connect with a Wi-Fi Modem via my iOS app. I don't want the user to go to Settings page and Activate Wi-Fi. Is it possible to achieve a Single Button - Pressed & Wi-Fi Connection Activated?
Thanks for your reply!!!
This is not possible unless you use Apple80211 private API, which will be rejected from the App Store.
Here's more information on how it's not possible, and here's a framework for jailbroken phones to use private API and seek/connect to a network.

Does a personal VPN created with NEVPNManager affect other apps?

I've found a few articles online such as this one which discuss using the new NetworkExtension.framework in iOS 8 and it's corresponding NEVPNManager class to create custom VPN configurations programatically.
It's implied that these configurations will only affect my app, and not other things in the background, but I've been unable to find anything definitive. The code references various things with names like sharedManager so it's not obvious.
So, if I create a VPN programatically with NEVPNManager and connect to it from within my iOS app, will it affect other apps and/or background services?
We're using NEVPNManager to connect VPN, that limits internet connectivity. All the apps on the device fail to connect their services, when our VPN is connected. However, some system services (like APNS) are still working somehow.

Connecting to a special wi-fi network via iPhone App

I have to build an App that connects to a special Wi-Fi network and the opens an Ip address that is only available withing the network.
Is it possible to connect to a special wi-fi network (say "Network XYZ") via iPhone App. If so, please let know, so that I have an idea how to solve this.
Sadly no. Not from within the app.
All you can do is instruct user to go to settings and connect to that network.
If iPhone was not registered to any WiFi network before entering your app and your app has usesWiFi key set to YES then user will get a list of available networks to choose from.
One more big problem is: there are no AdHoc networks on this list - only infrastructure networks. AdHoc networks are available only trough settings.
What you could do is to instruct your user to set the auto-join feature on for desired network.
I'm afraid the only way to change the network is via the Settings application. Otherwise, rogue apps might be able to move users to their own proxies without the user's knowing.
It may be possible on jailbroken devices, however, as you would no longer be confined to working within the usual app restrictions on accessing system-level settings.
You can have your app launch once the user connects to the SSID you specify using the CaptiveNetwork API.

Resources