Skip to content

Commit 63e91dc

Browse files
committed
Instructions for appbundle not connected
1 parent b618e18 commit 63e91dc

File tree

2 files changed

+131
-103
lines changed

2 files changed

+131
-103
lines changed

README.md

Lines changed: 115 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,84 @@
1-
Connect OpenVPN service with Flutter, Issues and PRs are very welcome!
1+
Connect to the OpenVPN service using Flutter. Contributions through issues and pull requests are highly appreciated!
22

33
## Android Setup
4-
### <b>1. Permission handler</b>
5-
#### JAVA
6-
Add this to your onActivityResult in MainActivity.java (if you are using Java)
4+
5+
### 1. Permission Handler
6+
7+
#### Java
8+
Include the following code in the `onActivityResult` method of `MainActivity.java` (if you are using Java):
79

810
```java
9-
OpenVPNFlutterPlugin.connectWhileGranted(requestCode == 24 && resultCode == RESULT_OK);
11+
OpenVPNFlutterPlugin.connectWhileGranted(requestCode == 24 && resultCode == RESULT_OK);
1012
```
11-
So it look like this
13+
14+
The complete method should look like this:
15+
1216
```java
13-
...
14-
import id.laskarmedia.openvpn_flutter.OpenVPNFlutterPlugin;
15-
...
16-
17-
@Override
18-
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
19-
OpenVPNFlutterPlugin.connectWhileGranted(requestCode == 24 && resultCode == RESULT_OK);
20-
super.onActivityResult(requestCode, resultCode, data);
21-
}
17+
...
18+
import id.laskarmedia.openvpn_flutter.OpenVPNFlutterPlugin;
19+
...
20+
21+
@Override
22+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
23+
OpenVPNFlutterPlugin.connectWhileGranted(requestCode == 24 && resultCode == RESULT_OK);
24+
super.onActivityResult(requestCode, resultCode, data);
25+
}
2226
```
2327

2428
#### Kotlin
25-
Add this to your onAcivityResult in MainActivity.kt (if you are using Kotlin)
29+
Include the following code in the `onActivityResult` method of `MainActivity.kt` (if you are using Kotlin):
2630

2731
```kotlin
28-
OpenVPNFlutterPlugin.connectWhileGranted(requestCode == 24 && resultCode == RESULT_OK);
32+
OpenVPNFlutterPlugin.connectWhileGranted(requestCode == 24 && resultCode == RESULT_OK);
2933
```
30-
So it look like this
34+
35+
The complete method should look like this:
36+
3137
```kotlin
32-
...
33-
import id.laskarmedia.openvpn_flutter.OpenVPNFlutterPlugin
34-
...
35-
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
36-
OpenVPNFlutterPlugin.connectWhileGranted(requestCode == 24 && resultCode == RESULT_OK)
37-
super.onActivityResult(requestCode, resultCode, data)
38-
}
38+
...
39+
import id.laskarmedia.openvpn_flutter.OpenVPNFlutterPlugin
40+
...
41+
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
42+
OpenVPNFlutterPlugin.connectWhileGranted(requestCode == 24 && resultCode == RESULT_OK)
43+
super.onActivityResult(requestCode, resultCode, data)
44+
}
45+
```
46+
47+
### 2. App Bundle Build Not Connecting
48+
49+
If you encounter issues with the app not connecting using the latest Flutter SDK, apply the following quick fix:
50+
51+
Ensure that you include the following attribute within the `<application>` tag in your `AndroidManifest.xml` file:
52+
53+
```xml
54+
<application
55+
...
56+
android:extractNativeLibs="true"
57+
...>
58+
</application>
3959
```
4060

4161
## iOS Setup
4262

43-
### <b>1. Add Capabillity</b>
44-
Add 2 capabillity on Runner's Target, <b>App Groups</b> and <b>Network Extensions</b>, Look at the image below to get clearer details
63+
### 1. Add Capabilities
64+
65+
Add the `App Groups` and `Network Extensions` capabilities to the Runner's target. Refer to the image below for detailed instructions:
4566

4667
<img src="https://blogger.googleusercontent.com/img/a/AVvXsEjYWGJ2ug4JM5g8_WslvdRY0Q-UUizOdmoCG8Ybhte9LiIv8_SSYFDHl-PzWApnAxvTA0hdpnBzca7C_zU5pHnyD8NLNoMw1ZOty7Zo6PTF22oIk7liB0aCXQnRAI1R0Zv9XfnuwuHuourtUR6lzf1ztrU_PTa6QFAU8kRPK-4h5MVu7QVzmpVs4Fvl=s600"/>
4768

48-
### <b>2. Add New Target</b>
49-
Click + button on bottom left, Choose <b>NETWORK EXTENSION</b>, and follow instruction's image bellow
69+
### 2. Add New Target
70+
71+
Click the `+` button on the bottom left, choose `NETWORK EXTENSION`, and follow the instructions in the image below:
5072

5173
<img src="https://blogger.googleusercontent.com/img/a/AVvXsEirvK1MMCqLADbXdtjppE-z1QC_cDPBnCWZ1EPkNLCM7TYyG3c2IGf8zlb1svW6aP6UB4eNOpX3svFwP_e9D0iP9Mb-dlXVtnUsYlg3iIQVqi_mmw4vLH5d8peEt7UGORikSlB3Hy0o1vj4XIBJNv5g8bIellHTXo4Zu4toh7Dt0jw4ZMyWDAoepLp7=s600"/>
5274

53-
Add Capabillity on VPNExtension, Do it same like Runner's Capabillitiy
75+
Add the same capabilities to the VPNExtension as you did for the Runner's target:
5476

5577
<img src="https://blogger.googleusercontent.com/img/a/AVvXsEgEj_1oXmgRSaVISGFHutY88enlUG1V8ynqfDHso-uS6vKEBLa-dhhChjZQ12iN7UpNM6thCHLmll3h6p_lW9URAPca-pXkwIN1pmATdfk3NnqnmlYtgUAicbr-zDZmNF7JJ4l4EArFtdrb_IjxH_FpLJGCURkpGO9qBtkw9WYs3k2vRSa3c8ga9b6S=s600"/>
5678

57-
### <b>3. Copy Paste</b>
58-
Add the following lines to your Podfile (`ios/Podfile`)
79+
### 3. Copy and Paste
80+
81+
Add the following lines to your Podfile (`ios/Podfile`):
5982

6083
```dart
6184
target 'VPNExtension' do
@@ -64,49 +87,48 @@ target 'VPNExtension' do
6487
end
6588
```
6689

67-
Open VPNExtension > PacketTunnelProvider.swift and copy paste this script <a href="https://raw.githubusercontent.com/nizwar/openvpn_flutter/master/example/ios/VPNExtension/PacketTunnelProvider.swift">PacketTunnelProvider.swift</a>
90+
Open `VPNExtension > PacketTunnelProvider.swift` and copy-paste the script from [PacketTunnelProvider.swift](https://raw.githubusercontent.com/nizwar/openvpn_flutter/master/example/ios/VPNExtension/PacketTunnelProvider.swift).
6891

6992
<img src="https://blogger.googleusercontent.com/img/a/AVvXsEhPf7Vl_8LPYMTTCn0UbpR3f3qzaFPFRMikSg8xetWRyfTuViq6o3fdrjU4-jD-xZtkOZV_i2WoNXkcHLn7znHengHZGgtlJlNbNk6vjNYgI2jYg8ToOYIQjR7QBd443ee4GqpEww0FYPrIiIpabUthpur6SakiPJM1dsDNCBW9ROWixuEzrk61aIod=s600">
7093

7194
## Note
72-
You must use iOS Devices instead of Simulator to connect
73-
7495

96+
You must use iOS devices instead of the simulator to connect.
7597

7698
## Recipe
7799

78100
### Initialize
79-
Before start, you have to initialize the OpenVPN plugin.
80101

81-
```dart
82-
late OpenVPN openvpn;
83-
84-
@override
85-
void initState() {
86-
openvpn = OpenVPN(onVpnStatusChanged: _onVpnStatusChanged, onVpnStageChanged: _onVpnStageChanged);
87-
openvpn.initialize(
88-
groupIdentifier: "GROUP_IDENTIFIER", ///Example 'group.com.laskarmedia.vpn'
89-
providerBundleIdentifier: "NETWORK_EXTENSION_IDENTIFIER", ///Example 'id.laskarmedia.openvpnFlutterExample.VPNExtension'
90-
localizedDescription: "LOCALIZED_DESCRIPTION" ///Example 'Laskarmedia VPN'
91-
);
92-
}
102+
Before starting, initialize the OpenVPN plugin:
93103

94-
void _onVpnStatusChanged(VPNStatus? vpnStatus){
95-
setState((){
96-
this.status = vpnStatus;
97-
});
98-
}
104+
```dart
105+
late OpenVPN openvpn;
106+
107+
@override
108+
void initState() {
109+
openvpn = OpenVPN(onVpnStatusChanged: _onVpnStatusChanged, onVpnStageChanged: _onVpnStageChanged);
110+
openvpn.initialize(
111+
groupIdentifier: "GROUP_IDENTIFIER", ///Example 'group.com.laskarmedia.vpn'
112+
providerBundleIdentifier: "NETWORK_EXTENSION_IDENTIFIER", ///Example 'id.laskarmedia.openvpnFlutterExample.VPNExtension'
113+
localizedDescription: "LOCALIZED_DESCRIPTION" ///Example 'Laskarmedia VPN'
114+
);
115+
}
99116
100-
void _onVpnStageChanged(VPNStage? stage){
101-
setState((){
102-
this.stage = stage;
103-
});
104-
}
117+
void _onVpnStatusChanged(VPNStatus? vpnStatus){
118+
setState((){
119+
this.status = vpnStatus;
120+
});
121+
}
105122
123+
void _onVpnStageChanged(VPNStage? stage){
124+
setState((){
125+
this.stage = stage;
126+
});
127+
}
106128
```
107129

108-
109130
### Connect to VPN
131+
110132
```dart
111133
void connect() {
112134
openvpn.connect(
@@ -115,36 +137,37 @@ void connect() {
115137
username: username,
116138
password: password,
117139
bypassPackages: [],
118-
// In iOS connection can stuck in "connecting" if this flag is "false".
140+
// In iOS connection can get stuck in "connecting" if this flag is "false".
119141
// Solution is to switch it to "true".
120142
certIsRequired: false,
121143
);
122144
}
123145
```
124146

125-
### Disconnect
147+
### Disconnect
148+
126149
```dart
127-
void disconnect(){
128-
openvpn.disconnect();
129-
}
150+
void disconnect(){
151+
openvpn.disconnect();
152+
}
130153
```
131154

132-
133155
# Publishing to Play Store and App Store
156+
134157
### Android
135-
1. You can use appbundle to publish the app
136-
2. Add this to your files in `android` folder (special thanks to https://github.com/nizwar/openvpn_flutter/issues/10). Otherwise connection will not be
137-
established in some cases and will siliently report "disconnected" when trying to connect. Most likely it's related to some symbols stripping by
138-
Google Play.
158+
159+
1. You can use app bundles to publish the app.
160+
2. Add the following to your files in the `android` folder (special thanks to https://github.com/nizwar/openvpn_flutter/issues/10). Otherwise, the connection may not be established in some cases and will silently report "disconnected" when trying to connect. This is likely related to some symbols being stripped by Google Play.
161+
139162
```
140163
gradle.properties > android.bundle.enableUncompressedNativeLibs=false
141-
AndroidManifest > android:extractNativeLibs="true" in application tag
164+
AndroidManifest > android:extractNativeLibs="true" in the application tag
142165
```
143166

144-
app/build.gradle add these inside android tag
145-
```gradle
167+
Add the following inside the `android` tag in `app/build.gradle`:
146168

147-
android{
169+
```gradle
170+
android {
148171
...
149172
//from here ======
150173
lintOptions {
@@ -175,26 +198,31 @@ android{
175198
```
176199

177200
#### Notifications
178-
As the plugin shows notification for connection status and connection detail, you have to request permission by using 3rd-party packages.
179201

180-
Example by using [permission_handler](https://pub.dev/packages/permission_handler)
202+
As the plugin shows notifications for connection status and connection details, you must request permission using third-party packages.
203+
204+
Example using [permission_handler](https://pub.dev/packages/permission_handler):
205+
181206
```dart
182-
///Put it anywhere you wish like once you initialize the vpn or pre-connect the server
183-
Permission.notification.isGranted.then((_) {
184-
if (!_) Permission.notification.request();
185-
});
207+
///Put it anywhere you wish, like once you initialize the VPN or pre-connect to the server
208+
Permission.notification.isGranted.then((_) {
209+
if (!_) Permission.notification.request();
210+
});
186211
```
187212

188-
189213
### iOS
190-
1. View [Apple Guidelines](https://developer.apple.com/app-store/review/guidelines/#vpn-apps) Relating to VPN
191-
2. This plugin DOES use Encryption BUT, It uses Exempt Encryptions
214+
215+
1. View [Apple Guidelines](https://developer.apple.com/app-store/review/guidelines/#vpn-apps) relating to VPN.
216+
2. This plugin DOES use encryption, but it uses exempt encryptions.
192217

193218
## Licenses
219+
194220
* [openvpn_flutter](https://github.com/nizwar/openvpn_flutter/blob/master/LICENSE) for this plugin
195-
* [ics-openvpn](https://github.com/schwabe/ics-openvpn) for Android Engine
196-
* [OpenVPNAdapter](https://github.com/ss-abramchuk/OpenVPNAdapter) for iOS Engine
197-
# Love my work?
198-
Don't forget to give me a 👍 &nbsp;or support me with a cup of ☕️
221+
* [ics-openvpn](https://github.com/schwabe/ics-openvpn) for the Android engine
222+
* [OpenVPNAdapter](https://github.com/ss-abramchuk/OpenVPNAdapter) for the iOS engine
223+
224+
# Support
225+
226+
If you appreciate my work, don't forget to give a thumbs up or support me with a cup of coffee.
199227

200-
<a href="https://paypal.me/nizwar/"><img src="https://raw.githubusercontent.com/andreostrovsky/donate-with-paypal/master/blue.svg" height="40"></a>
228+
<a href="https://paypal.me/nizwar/"><img src="https://raw.githubusercontent.com/andreostrovsky/donate-with-paypal/master/blue.svg" height="40"></a>

example/pubspec.lock

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ packages:
3737
dependency: transitive
3838
description:
3939
name: collection
40-
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
40+
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
4141
url: "https://pub.dev"
4242
source: hosted
43-
version: "1.18.0"
43+
version: "1.19.0"
4444
cupertino_icons:
4545
dependency: "direct main"
4646
description:
@@ -79,18 +79,18 @@ packages:
7979
dependency: transitive
8080
description:
8181
name: leak_tracker
82-
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
82+
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
8383
url: "https://pub.dev"
8484
source: hosted
85-
version: "10.0.5"
85+
version: "10.0.7"
8686
leak_tracker_flutter_testing:
8787
dependency: transitive
8888
description:
8989
name: leak_tracker_flutter_testing
90-
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
90+
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
9191
url: "https://pub.dev"
9292
source: hosted
93-
version: "3.0.5"
93+
version: "3.0.8"
9494
leak_tracker_testing:
9595
dependency: transitive
9696
description:
@@ -150,7 +150,7 @@ packages:
150150
dependency: transitive
151151
description: flutter
152152
source: sdk
153-
version: "0.0.99"
153+
version: "0.0.0"
154154
source_span:
155155
dependency: transitive
156156
description:
@@ -163,10 +163,10 @@ packages:
163163
dependency: transitive
164164
description:
165165
name: stack_trace
166-
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
166+
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
167167
url: "https://pub.dev"
168168
source: hosted
169-
version: "1.11.1"
169+
version: "1.12.0"
170170
stream_channel:
171171
dependency: transitive
172172
description:
@@ -179,10 +179,10 @@ packages:
179179
dependency: transitive
180180
description:
181181
name: string_scanner
182-
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
182+
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
183183
url: "https://pub.dev"
184184
source: hosted
185-
version: "1.2.0"
185+
version: "1.3.0"
186186
term_glyph:
187187
dependency: transitive
188188
description:
@@ -195,10 +195,10 @@ packages:
195195
dependency: transitive
196196
description:
197197
name: test_api
198-
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
198+
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
199199
url: "https://pub.dev"
200200
source: hosted
201-
version: "0.7.2"
201+
version: "0.7.3"
202202
vector_math:
203203
dependency: transitive
204204
description:
@@ -211,10 +211,10 @@ packages:
211211
dependency: transitive
212212
description:
213213
name: vm_service
214-
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
214+
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
215215
url: "https://pub.dev"
216216
source: hosted
217-
version: "14.2.5"
217+
version: "14.3.0"
218218
sdks:
219-
dart: ">=3.3.0 <4.0.0"
219+
dart: ">=3.4.0 <4.0.0"
220220
flutter: ">=3.18.0-18.0.pre.54"

0 commit comments

Comments
 (0)