flutter_vpn
flutter_vpn copied to clipboard
Has anyone got this working on iOS?
I am using the example in this package and has been successful getting it to work on Android with windscribe (as the VPN service) but it does not work on iOS. The example app shows connection state as 'connected' and Xcode logs 'VPN started successfully..' but is not really connected.
Changing the listener as below:
FlutterVpn.onStateChanged.listen((s) async {
var s2 = await FlutterVpn.currentState;
print('state: $s, currentState: $s2');
setState(() => state = s);
});
The following is printed: flutter: state: FlutterVpnState.connecting, currentState: FlutterVpnState.disconnected flutter: state: FlutterVpnState.connected, currentState: FlutterVpnState.disconnected
Therefore, it seems that the listener is being triggered incorrectly as the state has not changed at all.
Has anyone got this working on iOS? Any suggestions?
Hi rgb1380, The package does not work on ios simulation but, working OK on physical ios device. onStateChanged Listener does not work correctly on ios at all, you can try connectivity package to check the state respectively.
Thanks for the quick response. Can you please elaborate on how you are using the connectivity package to check the status.
By the way, I am using a physical device and the VPN icon does not appear in the status bar of the phone.
@rgb1380 The onStateChanged listener has been fixed on master branch. The changes will be released soon. If you want to try it, please use git dependency on master branch.
Dear @ctrysbita I am working with this package for several months now, I am thankful and excited to find this package to use as the core part of my project while I am facing many issues using it. I am checking your master channel very often and have seen that at the onStateChanged you have changed one variable from "state" to "states" to resolve the listener problem on ios, I have changed it manually on the package file implemented to the project by github too and found that it is triggering now after trying to connect/disconnect which means that it is working now. But, the listener changing very immediately after trying to connect/disconnect and not after connection/disconnection complete. I don't know if I am standing at the right point now but please correct me if I am wrong. I have a guess that the onStateChanged is triggering on finding connecting/disconnecting state and I am missing that part but, for now it is not helping me so much because if I depend my state change on the onStateChange listener it is triggering immediately right after each try of connecting/disconnecting process which makes the decision very hard to rely on onStateChange listener. Please let me know if I am missing something or should do check something else beside the onStateChanged. I know that the whole process of connection/disconnection process takes some while and I have to check the vpnState after listener triggered but it is not a reliable solution due to the fact that the state can be different after checking the vpnState during the process.
Thanks for your hard work and your useful feedback.
Thanks for the quick response. Can you please elaborate on how you are using the connectivity package to check the status.
By the way, I am using a physical device and the VPN icon does not appear in the status bar of the phone.
I believe you have read readme.md carefully by now and you should know that for ios part you need to add Personal VPN capability in xcode which means that you should have an apple developer account (not the free tier) and check the correct state and debugging results in the xcode console output not at the android studio or visual studio output.
About the connectivity package, you should read it and use its listener to find whenever the state of the connectivity has been changed and try to check the vpnState to find if it is connected/disconnected at the moment your connectivity listener has been triggered. It is my solution right now and I believe it is working very well by now. Even if your VPN connection lost because of the network or third-party apps, using connectivity listener can help you detect that to correct your app's state precisely.
Hope it helps you but I think it would be much better if the package authors release their new version to resolve the onStateChange problem on ios to get better result out of this useful package.
@rgb1380 The onStateChanged listener has been fixed on master branch. The changes will be released soon. If you want to try it, please use git dependency on master branch.
As I mentioned before, onStateChanged Listener is now working but just at connecting/disconnecting occasion! Whenever you start connecting to the VPN, the listener is getting a trigger and updating the status immediately shows a connecting state but the state change to connected will not trigger any even on the listener which makes it difficult to detect the connected/disconnected state of the VPN using this listener.
@rgb1380 The onStateChanged listener has been fixed on master branch. The changes will be released soon. If you want to try it, please use git dependency on master branch.
I am using the master branch and the example code. And have the issue that I described.
I believe you have read readme.md carefully by now and you should know that for ios part you need to add Personal VPN capability in xcode which means that you should have an apple developer account (not the free tier) and check the correct state and debugging results in the xcode console output not at the android studio or visual studio output.
@prooshani, I have set up xcode properly and have included Personal VPN and Network Extensions as described in readme.
When I connect the vpn, it pops up the warning message for adding the VPN configuration. The vpn configuration for the example app gets created but it does not connect to the vpn. Even if I try to to enable the VPN in iOS settings manually, it fails. I have created the same vpn configuration manually and can successfully connect. Any ideas, please?
I believe you have read readme.md carefully by now and you should know that for ios part you need to add Personal VPN capability in xcode which means that you should have an apple developer account (not the free tier) and check the correct state and debugging results in the xcode console output not at the android studio or visual studio output.
@prooshani, I have set up xcode properly and have included Personal VPN and Network Extensions as described in readme.
When I connect the vpn, it pops up the warning message for adding the VPN configuration. The vpn configuration for the example app gets created but it does not connect to the vpn. Even if I try to to enable the VPN in iOS settings manually, it fails. I have created the same vpn configuration manually and can successfully connect. Any ideas, please?
I'm wondering if you don't get any app related error then the problem is something in connection/server side. For example, recently I found that the serverAddress and remoteID are getting set together at this package which cause a lot of problem for me which I have modified the packages' codes to resolve it. Anyway, My app can connect to the VPN without problem now. If you think it would help you, you can share your connection setting for me to do a test for you.
@prooshani In my case remoteID and serverAddress must be the same and that's how configuring the VPN manually works. I really appreciate the offer to have you test it on your side. How can I send you a private message with the details?
same here, configurations get created but not working
@prooshani, Did you solve the problem? I got the same error.
@ rgb1380 Hello, could you let me know if you resolved this issue? I have the same issue as you, help me please
Unfortunately, did not resolve the issue and abandoned use of this plug-in
A solution was not found
@rgb1380 so now, what plug-in you are using to connect VPN ?
Ended up abandoing the idea of using a VPN as I did not find a suitable solution.