@capacitor/network 8.0.0-dev-2407-20250905T151500.0 → 8.0.0-dev-2411-20250905T165405.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CapacitorNetwork.podspec
CHANGED
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => 'https://github.com/ionic-team/capacitor-plugins.git', :tag => package['name'] + '@' + package['version'] }
|
|
13
13
|
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}', 'network/ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '15.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
|
17
17
|
end
|
package/Package.swift
CHANGED
package/android/build.gradle
CHANGED
|
@@ -31,10 +31,10 @@ if (System.getenv("CAP_PLUGIN_PUBLISH") == "true") {
|
|
|
31
31
|
|
|
32
32
|
android {
|
|
33
33
|
namespace "com.capacitorjs.plugins.network"
|
|
34
|
-
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
34
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
|
|
35
35
|
defaultConfig {
|
|
36
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
37
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
36
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
|
|
37
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
|
|
38
38
|
versionCode 1
|
|
39
39
|
versionName "1.0"
|
|
40
40
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
package com.capacitorjs.plugins.network;
|
|
2
2
|
|
|
3
|
-
import android.annotation.TargetApi;
|
|
4
3
|
import android.content.BroadcastReceiver;
|
|
5
4
|
import android.content.Context;
|
|
6
|
-
import android.content.Intent;
|
|
7
|
-
import android.content.IntentFilter;
|
|
8
5
|
import android.net.ConnectivityManager;
|
|
9
6
|
import android.net.ConnectivityManager.NetworkCallback;
|
|
10
7
|
import android.net.NetworkCapabilities;
|
|
11
|
-
import android.os.Build;
|
|
12
8
|
import androidx.annotation.NonNull;
|
|
13
9
|
import androidx.annotation.Nullable;
|
|
14
|
-
import androidx.annotation.RequiresApi;
|
|
15
|
-
import androidx.appcompat.app.AppCompatActivity;
|
|
16
10
|
|
|
17
11
|
public class Network {
|
|
18
12
|
|
|
@@ -50,21 +44,10 @@ public class Network {
|
|
|
50
44
|
* Create network monitoring object.
|
|
51
45
|
* @param context
|
|
52
46
|
*/
|
|
53
|
-
@SuppressWarnings("deprecation")
|
|
54
47
|
public Network(@NonNull Context context) {
|
|
55
48
|
this.context = context;
|
|
56
49
|
this.connectivityManager = (ConnectivityManager) this.context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
57
|
-
|
|
58
|
-
receiver =
|
|
59
|
-
new BroadcastReceiver() {
|
|
60
|
-
@Override
|
|
61
|
-
public void onReceive(Context context, Intent intent) {
|
|
62
|
-
statusChangeListener.onNetworkStatusChanged(false);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
} else {
|
|
66
|
-
this.connectivityCallback = new ConnectivityCallback();
|
|
67
|
-
}
|
|
50
|
+
this.connectivityCallback = new ConnectivityCallback();
|
|
68
51
|
}
|
|
69
52
|
|
|
70
53
|
/**
|
|
@@ -90,26 +73,22 @@ public class Network {
|
|
|
90
73
|
*/
|
|
91
74
|
public NetworkStatus getNetworkStatus() {
|
|
92
75
|
NetworkStatus networkStatus = new NetworkStatus();
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
networkStatus.connectionType = NetworkStatus.ConnectionType.UNKNOWN;
|
|
108
|
-
}
|
|
76
|
+
if (this.connectivityManager != null) {
|
|
77
|
+
android.net.Network activeNetwork = this.connectivityManager.getActiveNetwork();
|
|
78
|
+
NetworkCapabilities capabilities =
|
|
79
|
+
this.connectivityManager.getNetworkCapabilities(this.connectivityManager.getActiveNetwork());
|
|
80
|
+
if (activeNetwork != null && capabilities != null) {
|
|
81
|
+
networkStatus.connected =
|
|
82
|
+
capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED) &&
|
|
83
|
+
capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
|
|
84
|
+
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
|
|
85
|
+
networkStatus.connectionType = NetworkStatus.ConnectionType.WIFI;
|
|
86
|
+
} else if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
|
|
87
|
+
networkStatus.connectionType = NetworkStatus.ConnectionType.CELLULAR;
|
|
88
|
+
} else {
|
|
89
|
+
networkStatus.connectionType = NetworkStatus.ConnectionType.UNKNOWN;
|
|
109
90
|
}
|
|
110
91
|
}
|
|
111
|
-
} else {
|
|
112
|
-
networkStatus = getAndParseNetworkInfo();
|
|
113
92
|
}
|
|
114
93
|
return networkStatus;
|
|
115
94
|
}
|
|
@@ -133,27 +112,14 @@ public class Network {
|
|
|
133
112
|
/**
|
|
134
113
|
* Register a network callback.
|
|
135
114
|
*/
|
|
136
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
137
115
|
public void startMonitoring() {
|
|
138
116
|
connectivityManager.registerDefaultNetworkCallback(connectivityCallback);
|
|
139
117
|
}
|
|
140
118
|
|
|
141
|
-
@TargetApi(Build.VERSION_CODES.M)
|
|
142
|
-
public void startMonitoring(AppCompatActivity activity) {
|
|
143
|
-
IntentFilter filter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
|
|
144
|
-
activity.registerReceiver(receiver, filter);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
119
|
/**
|
|
148
120
|
* Unregister the network callback.
|
|
149
121
|
*/
|
|
150
|
-
@RequiresApi(api = Build.VERSION_CODES.N)
|
|
151
122
|
public void stopMonitoring() {
|
|
152
123
|
connectivityManager.unregisterNetworkCallback(connectivityCallback);
|
|
153
124
|
}
|
|
154
|
-
|
|
155
|
-
@TargetApi(Build.VERSION_CODES.M)
|
|
156
|
-
public void stopMonitoring(@NonNull AppCompatActivity activity) {
|
|
157
|
-
activity.unregisterReceiver(receiver);
|
|
158
|
-
}
|
|
159
125
|
}
|
|
@@ -56,11 +56,7 @@ public class NetworkPlugin extends Plugin {
|
|
|
56
56
|
*/
|
|
57
57
|
@Override
|
|
58
58
|
protected void handleOnResume() {
|
|
59
|
-
|
|
60
|
-
implementation.startMonitoring();
|
|
61
|
-
} else {
|
|
62
|
-
implementation.startMonitoring(getActivity());
|
|
63
|
-
}
|
|
59
|
+
implementation.startMonitoring();
|
|
64
60
|
NetworkStatus afterPauseNetworkStatus = implementation.getNetworkStatus();
|
|
65
61
|
if (
|
|
66
62
|
prePauseNetworkStatus != null &&
|
|
@@ -82,11 +78,7 @@ public class NetworkPlugin extends Plugin {
|
|
|
82
78
|
@Override
|
|
83
79
|
protected void handleOnPause() {
|
|
84
80
|
this.prePauseNetworkStatus = implementation.getNetworkStatus();
|
|
85
|
-
|
|
86
|
-
implementation.stopMonitoring();
|
|
87
|
-
} else {
|
|
88
|
-
implementation.stopMonitoring(getActivity());
|
|
89
|
-
}
|
|
81
|
+
implementation.stopMonitoring();
|
|
90
82
|
}
|
|
91
83
|
|
|
92
84
|
private void updateNetworkStatus() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/network",
|
|
3
|
-
"version": "8.0.0-dev-
|
|
3
|
+
"version": "8.0.0-dev-2411-20250905T165405.0",
|
|
4
4
|
"description": "The Network API provides network and connectivity information.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"publish:cocoapod": "pod trunk push ./CapacitorNetwork.podspec --allow-warnings"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@capacitor/android": "
|
|
51
|
-
"@capacitor/core": "
|
|
50
|
+
"@capacitor/android": "next",
|
|
51
|
+
"@capacitor/core": "next",
|
|
52
52
|
"@capacitor/docgen": "0.2.2",
|
|
53
|
-
"@capacitor/ios": "
|
|
53
|
+
"@capacitor/ios": "next",
|
|
54
54
|
"@ionic/eslint-config": "^0.4.0",
|
|
55
55
|
"@ionic/prettier-config": "~1.0.1",
|
|
56
56
|
"@ionic/swiftlint-config": "^1.1.2",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"typescript": "~4.1.5"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@capacitor/core": "
|
|
66
|
+
"@capacitor/core": "next"
|
|
67
67
|
},
|
|
68
68
|
"prettier": "@ionic/prettier-config",
|
|
69
69
|
"swiftlint": "@ionic/swiftlint-config",
|