I'm trying to set up an in-app VPN connection using ios8's VPN configuration and control but I'm stuck. I'm using the resources at http://ramezanpour.net/post/2014/08/03/configure-and-manage-vpn-connections-programmatically-in-ios-8/ to help, but I'm having problems binding the protocol to the VPN manager.
So far, I have the following code, and as per the tutorial above, you then need to bind the protocol to the manager...
func initVPN() {
let manager: NEVPNManager = NEVPNManager.sharedManager()
let p = NEVPNProtocolIPSec()
p.username = "ospencer"
p.passwordReference = getPasscodeNSData("vpnPassword")
p.serverAddress = "vconnect.uk.capgemini.com"
p.authenticationMethod = NEVPNIKEAuthenticationMethod.SharedSecret
p.sharedSecretReference = getPasscodeNSData("vpnSharedSecret")
p.useExtendedAuthentication = true
p.disconnectOnSleep = false
I've tried writing manager.protocol = p, but I get the error "expected member name following ." and "expected identifier in protocol declaration". I've tried a setProtocol function that is used in some of the Objective C examples '[manager setProtocol:p]', but that doesn't seem to exist in the latest xcode build.
Can anyone help? Also there appears to be almost no details about using the VPN functionality on the internet - even on Apple's site. Any pointers would be useful.
Thanks,
Oliver.
To use a reserved word as an identifier, put a backtick (`) before and after it. For example, class is not a valid identifier, but
class
is valid. The backticks are not considered part of the identifier;x
and x have the same meaning.
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With