Connect VPN automatically by Domain

Hi,

I am working on a device level VPN(non per-app VPN) with NetworkExtension framework, one of my cases is connect VPN automatically when user access some specific domains, for example "google.com, facebook.com".So how to start the VPN automatically by system with "Connect On Demand" rules or some else approach? I've tried with below rule, but not work.
                //configurating here
                manager.protocolConfiguration = config
                let onDemandRule1 = NEOnDemandRuleConnect()
                onDemandRule1.DNSSearchDomainMatch = ["*.google.com","*.facebook.com"]

                manager.onDemandRules = [onDemandRule1]
                manager.onDemandEnabled = true
                manager.saveToPreferencesWithCompletionHandler({ (err2) -> Void in
                    //error
                })

Replies

I recommend that you prototype this using a configuration profile before you go to the trouble of writing it in code. You’ll find the following documents useful:

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks for your quick reponse and your useful info, I did try with pushing profile with same rule to my device, but unfortunately it is not working either. I want to confirm whether or not it is correct way to meet my case by setting onDemandRule as NEOnDemandRuleConnect and sepecify DNSSearchDomainMatch with domain like "*.google.com", if not, what is the correct way?


Thanks!

I’m sorry but I don’t have sufficient experience with setting up VPN On Demand to answer those questions [1].

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

[1] Note that both of the references in my previous post point to technologies supported by Apple Support, not DTS.