1
- # Wifi Manager for .NET MAUI
1
+ # Wi-Fi Manager for .NET MAUI
2
2
3
- Welcome to the documentation for the MAUI Wi-Fi Manager library, a comprehensive solution designed specifically for MAUI. This library empowers developers to effortlessly manage Wi-Fi networks within their cross-platform applications . With its intuitive APIs , you can seamlessly integrate Wi-Fi functionality, allowing users to connect to, add, and retrieve information about Wi-Fi networks with ease .
3
+ The Wi-Fi Manager for .NET MAUI is a simple and powerful library that helps you manage Wi-Fi networks in your cross-platform apps . With this library , you can easily connect to Wi-Fi networks, retrieve network information, and provide quick access to Wi-Fi and wireless settings .
4
4
5
5
[ ![ WifiManager.Maui] ( https://img.shields.io/nuget/v/WifiManager.Maui )] ( https://www.nuget.org/packages/WifiManager.Maui/ )
6
6
7
+ ---
7
8
8
- ## Platform Support
9
+ ## Supported Platforms
9
10
10
- | S. No. | Platform | Support | Remarks |
11
- | ------ | ------------ | --------- | ----------- |
12
- | 1. | Android | &# 9745 ; | |
13
- | 2. | iOS | &# 9745 ; | |
14
- | 3. | Windows | &# 9745 ; | |
15
- | 4. | Mac | &#x 2612 ; | Coming Soon |
16
- | 5. | Tizen | &#x 2612 ; | Coming Soon |
11
+ | Platform | Supported | Notes |
12
+ | -----------| ----------- | ---------------------------------- |
13
+ | Android | ✅ | |
14
+ | iOS | ✅ | |
15
+ | Windows | ✅ | |
16
+ | Mac | ❌ | |
17
+ | Tizen | ❌ | |
17
18
18
- ## Features
19
+ ---
19
20
20
- - Connect Wi-Fi with SSID and Password: Enable users to connect to Wi-Fi networks by providing the SSID and password.
21
- - Add a New Wi-Fi Network: Seamlessly add new Wi-Fi networks to the device.
22
- - Get Current Network Info: Retrieve information about the currently connected Wi-Fi network.
23
- - Disconnect Wi-Fi: Allow users to disconnect from a Wi-Fi network.
24
- - Open Wi-Fi Setting: Provide a quick way for users to access their device's Wi-Fi settings.
21
+ ## Key Features
25
22
26
- ## Getting started
23
+ - ** Connect to Wi-Fi** : Connect to Wi-Fi networks using SSID and password.
24
+ - ** Get Network Info** : View details about the currently connected network.
25
+ - ** Disconnect Wi-Fi** : Disconnect from a specific Wi-Fi network.
26
+ - ** Open Wi-Fi Settings** : Provide quick access to device Wi-Fi settings.
27
+ - ** Open Wireless Settings** : Provide quick access to device wireless settings.
28
+
29
+ ---
30
+
31
+ ## How to Get Started
27
32
28
33
### Initialization
29
34
30
- Before using the MAUI Wi-Fi Manager plugin in your application, it's essential to initialize it. Here's how to do it on different platforms :
35
+ Before using the library, make sure to initialize it properly :
31
36
32
- #### Android
37
+ #### For Android
33
38
34
- To use the MAUI Wi-Fi Manager on Android, you must initialize the plugin. Add the following code to your Android application :
39
+ Add the following to your Android app initialization :
35
40
36
41
``` csharp
37
- WifiNetworkService .Init (this );
42
+ WifiNetworkService .Init (this );
38
43
```
39
44
40
- Android Permissions
45
+ Also, include these permissions in your ` AndroidManifest.xml ` file:
41
46
42
47
``` xml
43
48
<uses-permission android : name =" android.permission.ACCESS_WIFI_STATE" />
@@ -48,120 +53,113 @@ Android Permissions
48
53
<uses-permission android : name =" android.permission.ACCESS_COARSE_LOCATION" />
49
54
```
50
55
51
- Make sure you request location before scanning Wi-Fi
56
+ Make sure to request location permissions before scanning for Wi-Fi.
52
57
53
- #### iOS
58
+ #### For iOS
54
59
55
- Add wifi-info and HotspotConfiguration in Entitlements.plist
60
+ Add the following to your ` Entitlements.plist ` :
56
61
57
62
``` xml
58
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
59
- <plist version =" 1.0" >
60
- <dict >
61
- <key >com.apple.developer.networking.wifi-info</key >
62
- <true />
63
- <key >com.apple.developer.networking.HotspotConfiguration</key >
64
- <true />
65
- </dict >
66
- </plist >
63
+ <key >com.apple.developer.networking.wifi-info</key >
64
+ <true />
65
+ <key >com.apple.developer.networking.HotspotConfiguration</key >
66
+ <true />
67
67
```
68
68
69
- Request location permission on info.plist
69
+ In ` Info.plist ` , request location permissions:
70
70
71
71
``` xml
72
72
<key >NSLocationWhenInUseUsageDescription</key >
73
- <string >App want to access location to get ssid </string >
73
+ <string >The app needs location access to detect Wi-Fi networks. </string >
74
74
```
75
75
76
- Example
76
+ ---
77
77
78
- ``` csharp
79
- PermissionStatus status = await Permissions .RequestAsync <Permissions .LocationWhenInUse >();
80
- if (status == PermissionStatus .Granted )
81
- {
82
- var response = await CrossWifiManager .Current .ScanWifiNetworks ();
83
- }
84
- else
85
- await DisplayAlert (" No location permission" , " Please provide location permission" , " OK" );
86
- ```
78
+ ## Examples
87
79
88
- #### Connect to Wi-Fi
80
+ ### Connect to Wi-Fi
89
81
90
- To connect to a Wi-Fi network programmatically, use the ConnectWifi method. This method takes the SSID and password as parameters. Here's an example :
82
+ To connect to a Wi-Fi network:
91
83
92
84
``` csharp
93
- var response = await CrossWifiManager .Current .ConnectWifi (ssid , password );
85
+ var response = await CrossWifiManager .Current .ConnectWifi (" your-SSID " , " your- password" );
94
86
```
95
87
96
- The NetworkData class is defined as follows:
88
+ ---
89
+
90
+ ### Scan for Available Networks
91
+
92
+ To get a list of available Wi-Fi networks (Android & Windows only):
97
93
98
94
``` csharp
99
- public class NetworkData
100
- {
101
- public int StausId { get ; set ; }
102
- public string Ssid { get ; set ; }
103
- public int IpAddress { get ; set ; }
104
- public string GatewayAddress { get ; set ; }
105
- public object NativeObject { get ; set ; }
106
- public object Bssid { get ; set ; }
107
- public object SignalStrength { get ; set ; }
108
- }
95
+ var response = await CrossWifiManager .Current .ScanWifiNetworks ();
109
96
```
110
97
111
- #### Scan available Wi-Fi (Not available on iOS)
98
+ ---
112
99
113
- You can access available Wi-Fi networks using the ScanWifiNetworks method (Available on Android & Windows):
100
+ ### Get Current Network Info
101
+
102
+ To retrieve details of the currently connected Wi-Fi network:
114
103
115
104
``` csharp
116
- var response = await CrossWifiManager .Current .ScanWifiNetworks ();
105
+ var response = await CrossWifiManager .Current .GetNetworkInfo ();
117
106
```
118
107
119
- #### Get Wi-Fi info
108
+ ---
109
+
110
+ ### Disconnect Wi-Fi
120
111
121
- You can retrieve information about the currently connected Wi-Fi network using the GetNetworkInfo method :
112
+ To disconnect from a Wi-Fi network:
122
113
123
114
``` csharp
124
- var response = await CrossWifiManager .Current .GetNetworkInfo ( );
115
+ await CrossWifiManager .Current .DisconnectWifi ( " your-SSID " );
125
116
```
126
117
127
- #### Disconnect Wi-Fi
118
+ ---
128
119
129
- To disconnect from a Wi-Fi network, simply call the DisconnectWifi method with the SSID as a parameter:
120
+ ### Open Wireless Settings
121
+
122
+ To open the device's wireless settings:
130
123
131
124
``` csharp
132
- CrossWifiManager .Current .DisconnectWifi ( ssid );
125
+ await CrossWifiManager .Current .OpenWirelessSetting ( );
133
126
```
134
127
135
- #### Open Wi-Fi Setting
128
+ ** Note** : On iOS, this opens the app's settings instead of wireless settings.
129
+
130
+ ---
136
131
137
- If you want to provide users with a convenient way to access their device's Wi-Fi settings, use the OpenWifiSetting method:
132
+ ### Open Wi-Fi Settings
133
+
134
+ To provide quick access to Wi-Fi settings:
138
135
139
136
``` csharp
140
- var response = await CrossWifiManager .Current .OpenWifiSetting ();
137
+ await CrossWifiManager .Current .OpenWifiSetting ();
141
138
```
142
139
143
- I value your feedback! If you encounter any issues, have suggestions for improvement, or wish to report bugs, please open an issue on GitHub or GitLab repository
140
+ ** Note ** : On iOS, this opens the app's settings instead of Wi-Fi settings.
144
141
145
- ## License
142
+ ---
146
143
147
- MIT License
144
+ ## Feature Support by Platform
148
145
149
- Copyright (c) 2023 Santosh Dahal
146
+ | Feature | Android | iOS | Windows | Notes |
147
+ | ----------------------------------| ---------| -----------| ---------| -----------------------------------------|
148
+ | Connect to Wi-Fi | ✅ | ✅ | ✅ | Supported on all platforms. |
149
+ | Get Current Network Info | ✅ | ✅ | ✅ | Supported on all platforms. |
150
+ | Disconnect Wi-Fi | ✅ | ✅ | ✅ | Supported on all platforms. |
151
+ | Scan for Available Wi-Fi Networks| ✅ | ❌ | ✅ | Not supported on iOS. |
152
+ | Open Wireless Settings | ✅ | ✅* | ✅ | * Opens app settings on iOS. |
153
+ | Open Wi-Fi Settings | ✅ | ✅* | ✅ | * Opens app settings on iOS. |
150
154
151
- Permission is hereby granted, free of charge, to any person obtaining a copy
152
- of this software and associated documentation files (the "Software"), to deal
153
- in the Software without restriction, including without limitation the rights
154
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
155
- copies of the Software, and to permit persons to whom the Software is
156
- furnished to do so, subject to the following conditions:
155
+ ---
157
156
158
- The above copyright notice and this permission notice shall be included in all
159
- copies or substantial portions of the Software.
157
+ ## Feedback & Issues
158
+
159
+ If you encounter any issues or have suggestions, please open an issue on the project's GitHub or GitLab repository.
160
+
161
+ ---
162
+
163
+ ## License
160
164
161
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
162
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
163
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
164
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
165
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
166
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
167
- SOFTWARE.
165
+ This project is licensed under the MIT License. See the [ LICENSE] ( LICENSE ) file for details.
0 commit comments