Skip to content

Commit c6dc867

Browse files
feat: Update ad permission description for clarity and improve WebView privacy handling
1 parent 21e1f5c commit c6dc867

4 files changed

Lines changed: 66 additions & 14 deletions

File tree

android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
android:label="DefyxVPN"
2828
android:icon="@mipmap/ic_launcher"
2929
android:banner="@drawable/tv_banner"
30+
android:usesCleartextTraffic="true"
3031
tools:ignore="ForegroundServicePermission">
3132

3233
<receiver

ios/Runner/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<key>NSVPNConfigurationUsageDescription</key>
3434
<string>Defyx needs access to VPN configurations to secure your connection.</string>
3535
<key>NSUserTrackingUsageDescription</key>
36-
<string>We show personalized ads to support this free VPN service. Your data stays private and secure.</string>
36+
<string>We need permission to show you personalized ads. This helps support our free VPN service. Declining means you'll see generic ads instead.</string>
3737
<key>NSPhotoLibraryUsageDescription</key>
3838
<string>Defyx needs access to your photo library to let you select and share images, such as profile pictures or VPN connection QR codes.</string>
3939
<key>UIApplicationSupportsIndirectInputEvents</key>

lib/shared/layout/navbar/widgets/custom_webview_screen.dart

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
44
import 'package:flutter_screenutil/flutter_screenutil.dart';
55
import 'package:url_launcher/url_launcher.dart';
66
import 'package:webview_flutter/webview_flutter.dart';
7+
import 'package:webview_flutter_android/webview_flutter_android.dart';
8+
import 'package:webview_flutter_wkwebview/webview_flutter_wkwebview.dart';
79

810
class CustomWebViewScreen extends StatefulWidget {
911
final String url;
@@ -20,7 +22,7 @@ class CustomWebViewScreen extends StatefulWidget {
2022
}
2123

2224
class _CustomWebViewScreenState extends State<CustomWebViewScreen> {
23-
late final WebViewController _controller;
25+
WebViewController? _controller;
2426
bool _isLoading = true;
2527

2628
@override
@@ -32,23 +34,69 @@ class _CustomWebViewScreenState extends State<CustomWebViewScreen> {
3234
return;
3335
}
3436

35-
_controller = WebViewController()
37+
_initializeWebView();
38+
}
39+
40+
Future<void> _initializeWebView() async {
41+
// Clear all cookies before loading to prevent tracking
42+
await WebViewCookieManager().clearCookies();
43+
44+
// Use platform-specific params for native cookie blocking
45+
late final PlatformWebViewControllerCreationParams params;
46+
47+
if (Platform.isIOS) {
48+
// iOS: Use WKWebView which blocks 3rd-party cookies by default (iOS 14+)
49+
params = WebKitWebViewControllerCreationParams(
50+
allowsInlineMediaPlayback: true,
51+
mediaTypesRequiringUserAction: const {},
52+
);
53+
} else if (Platform.isAndroid) {
54+
// Android: Use native WebView with built-in privacy features
55+
params = AndroidWebViewControllerCreationParams();
56+
} else {
57+
params = const PlatformWebViewControllerCreationParams();
58+
}
59+
60+
final controller = WebViewController.fromPlatformCreationParams(params)
3661
..setJavaScriptMode(JavaScriptMode.unrestricted)
3762
..setNavigationDelegate(
3863
NavigationDelegate(
39-
onPageStarted: (String url) {
40-
setState(() {
41-
_isLoading = true;
42-
});
64+
onNavigationRequest: (NavigationRequest request) {
65+
// Clear cookies before every navigation to prevent tracking persistence
66+
WebViewCookieManager().clearCookies();
67+
debugPrint('🍪 Cookies cleared before navigation to: ${request.url}');
68+
return NavigationDecision.navigate;
69+
},
70+
onPageStarted: (String url) async {
71+
// Clear cookies when page starts loading as an additional safeguard
72+
await WebViewCookieManager().clearCookies();
73+
if (mounted) {
74+
setState(() {
75+
_isLoading = true;
76+
});
77+
}
4378
},
4479
onPageFinished: (String url) {
45-
setState(() {
46-
_isLoading = false;
47-
});
80+
if (mounted) {
81+
setState(() {
82+
_isLoading = false;
83+
});
84+
}
4885
},
4986
),
5087
)
51-
..loadRequest(Uri.parse(widget.url));
88+
..setUserAgent('Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 DNT/1');
89+
90+
// Load the URL
91+
await controller.loadRequest(Uri.parse(widget.url));
92+
93+
_controller = controller;
94+
95+
if (mounted) {
96+
setState(() {});
97+
}
98+
99+
debugPrint('🍪 WebView initialized: Native privacy + continuous cookie blocking');
52100
}
53101

54102
Future<void> _openInBrowser() async {
@@ -137,7 +185,10 @@ class _CustomWebViewScreenState extends State<CustomWebViewScreen> {
137185
),
138186
body: Stack(
139187
children: [
140-
WebViewWidget(controller: _controller),
188+
if (_controller != null)
189+
WebViewWidget(controller: _controller!)
190+
else
191+
const SizedBox.shrink(),
141192
if (_isLoading)
142193
Center(
143194
child: CircularProgressIndicator(

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: defyx_vpn
22
description: "A new Vpn app"
33
publish_to: "none"
4-
version: 5.0.7+247
4+
version: 5.1.2+249
55

66
environment:
77
sdk: ^3.8.0
@@ -105,7 +105,7 @@ msix_config:
105105
display_name: Defyx VPN
106106
publisher_display_name: UnboundTech UG
107107
identity_name: UnboundTechUG.6065AEC5A207
108-
msix_version: 5.0.7.247
108+
msix_version: 5.1.2.249
109109
publisher: "CN=62937938-2AE2-4C12-9ED8-4C418C0CADF2"
110110
logo_path: assets/images/logo.png
111111
capabilities: runFullTrust,internetClientServer,privateNetworkClientServer,unvirtualizedResources

0 commit comments

Comments
 (0)