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: set timeout param for iOS as nonnull instead of nullable, as React requires #397

Merged
merged 2 commits into from
Sep 12, 2024
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
15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This project is based on the no longer maintained https://github.com/robwalkerco

## Getting started

`$ npm install react-native-wifi-reborn --save`
`$ npm install react-native-wifi-reborn`

### iOS

Expand Down Expand Up @@ -171,18 +171,7 @@ _The api documentation is in progress._

The following methods work on both Android and iOS

### ```### NEW VERSION WITH OPTIONAL PARAMETERS ###```
```
connectToProtectedWifiSSID({
ssid: string;
password: string | null;
isWEP?: boolean;
isHidden?: boolean;
timeout?: number
;}): Promise
```

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

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

Expand Down
5 changes: 3 additions & 2 deletions ios/RNWifi.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ + (BOOL)requiresMainQueueSetup
RCT_EXPORT_METHOD(connectToSSID:(NSString*)ssid
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
[self connectToProtectedSSID:ssid withPassphrase:@"" isWEP:false isHidden:false timeout:nil resolver:resolve rejecter:reject];
NSNumber *defaultTimeout = @(0); // Provide a default value for timeout, fix issue #379
[self connectToProtectedSSID:ssid withPassphrase:@"" isWEP:false isHidden:false timeout:defaultTimeout resolver:resolve rejecter:reject];
}

RCT_EXPORT_METHOD(connectToSSIDPrefix:(NSString*)ssid
Expand Down Expand Up @@ -131,7 +132,7 @@ + (BOOL)requiresMainQueueSetup
withPassphrase:(NSString*)passphrase
isWEP:(BOOL)isWEP
isHidden:(BOOL)isHidden
timeout:(nullable NSNumber *)timeout
timeout:(nonnull NSNumber *)timeout // Explicitly mark timeout as nonnull, fix issue #379
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
[self connectToProtectedSSIDOnce:ssid withPassphrase:passphrase isWEP:isWEP joinOnce:false resolver:resolve rejecter:reject];
Expand Down
Loading