Closed hungrytocode closed 5 years ago
Hi @hungrytocode, you don't need adapter in the main app. It is sufficient to send just statistic there. You can do it using UserDefaults initialized with custom suite name.
Hi @hungrytocode, you don't need adapter in the main app. It is sufficient to send just statistic there. You can do it using UserDefaults initialized with custom suite name.
oh,thanks,and can you tell me where i can write data with UserDefaults in extension and where i should read data with UserDefaults in main app.
@hungrytocode : you can also fetch traffic stats without using Userdefaults by the following way.
You can use func handleAppMessage(_ messageData: Data, completionHandler: ((Data?) -> Void)? = nil) delegate method of NEPacketTunnelProvider and fetch transport stats using vpnAdapter.transportStatistics.bytesIn and vpnAdapter.transportStatistics.bytesOut.
In your host app, you can fetch session from providerManager?.connection as? NETunnelProviderSession instance and then use method sendProviderMessage
I hope it will help you!!
hi , what I get when using vpnAdapter.transportStatistics.bytesOut/bytesIn is zero all the time, can you explain more with an example??
i want to use transportStatistics property in OpenVPNAdapter class ,but how can i transport this property in PacketTunnelProvider.m class to my UI controller to use this property.