Skip to content

Commit

Permalink
fix(iOS): add missing isHidden flag to connectToProtectedSSID (JuanSe…
Browse files Browse the repository at this point in the history
…Bestia#306)

Follow-up PR on JuanSeBestia#287. That PR introduced an extra param on Android but not on iOS, causing the method to fail.
  • Loading branch information
robrechtme authored May 26, 2023
1 parent da1cbf9 commit 11a703d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
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
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

0 comments on commit 11a703d

Please sign in to comment.