Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iOS): add missing isHidden flag to connectToProtectedSSID #306

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ _The api documentation is in progress._

The following methods work on both Android and iOS

### `connectToProtectedSSID(SSID: string, password: string, isWEP: boolean): Promise`
### `connectToProtectedSSID(SSID: string, password: string, isWEP: boolean, isHidden: boolean): Promise`

Returns a promise that resolves when connected or rejects with the error when it couldn't connect to the wifi network.

Expand All @@ -188,9 +188,15 @@ Type: `string`
The password of the wifi network to connect with.

#### isWep

Type: `boolean`
Used on iOS. If true, the network is WEP Wi-Fi; otherwise it is a WPA or WPA2 personal Wi-Fi network.

#### isHidden

Type: `boolean`
Used on Android. If true, the network is a hidden Wi-Fi network.

#### Errors:
* iOS:
* `unavailableForOSVersion`: Starting from iOS 11, NEHotspotConfigurationError is available.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void setEnabled(final boolean enabled) {
* @param SSID name of the network to connect with
* @param password password of the network to connect with
* @param isWep only for iOS
* @param isHidden only for android, use if WiFi is hidden
* @param isHidden only for Android, use if WiFi is hidden
* @param promise to send success/error feedback
*/
@ReactMethod
Expand Down
1 change: 1 addition & 0 deletions example/RNWifiReborn/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const App = () => {
ssid,
password,
false,
false,
);
console.log('Connected successfully!', {data});
setConnected({connected: true, ssid});
Expand Down
3 changes: 2 additions & 1 deletion ios/RNWifi.m
robrechtme marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ + (BOOL)requiresMainQueueSetup
RCT_EXPORT_METHOD(connectToSSID:(NSString*)ssid
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
[self connectToProtectedSSID:ssid withPassphrase:@"" isWEP:false resolver:resolve rejecter:reject];
[self connectToProtectedSSID:ssid withPassphrase:@"" isWEP:false isHidden:false resolver:resolve rejecter:reject];
}

RCT_EXPORT_METHOD(connectToSSIDPrefix:(NSString*)ssid
Expand Down Expand Up @@ -120,6 +120,7 @@ + (BOOL)requiresMainQueueSetup
RCT_EXPORT_METHOD(connectToProtectedSSID:(NSString*)ssid
withPassphrase:(NSString*)passphrase
isWEP:(BOOL)isWEP
isHidden:(BOOL)isHidden
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
[self connectToProtectedSSIDOnce:ssid withPassphrase:passphrase isWEP:isWEP joinOnce:false resolver:resolve rejecter:reject];
Expand Down
2 changes: 1 addition & 1 deletion lib/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ declare module 'react-native-wifi-reborn' {
* @param SSID Wifi name.
* @param password `null` for open networks.
* @param isWep Used on iOS. If `true`, the network is WEP Wi-Fi; otherwise it is a WPA or WPA2 personal Wi-Fi network.
* @param isHidden only for android, use if WiFi is hidden
* @param isHidden only for Android, use if Wi-Fi is hidden.
*/
export function connectToProtectedSSID(
SSID: string,
Expand Down