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

Remove unused timeout parameter from iOS WiFi connection methods #425

Merged

Conversation

dawidzawada
Copy link
Contributor

@dawidzawada dawidzawada commented Jan 19, 2025

When a user denies the WiFi connection prompt on iOS, the app crashes without any error message. This happens when calling connectToProtectedSSID.

This fixes #424

XCode's catched crash error:

Thread 1: EXC_BAD_ACCESS (code=1, address=0x10)
image

Root Cause

The iOS implementation includes a timeout parameter that isn't used and isn't defined in TypeScript types:

TypeScript definition:

connectToProtectedSSID(
  ssid: string, 
  password: string, 
  isWEP: boolean, 
  isHidden: boolean
): Promise<void>;

Native method implementation:

RCT_EXPORT_METHOD(connectToProtectedSSID:(NSString*)ssid
                  withPassphrase:(NSString*)passphrase
                  isWEP:(BOOL)isWEP
                  isHidden:(BOOL)isHidden
                  timeout:(nonnull NSNumber *)timeout // Extra parameter
                  resolver:(RCTPromiseResolveBlock)resolve
                  rejecter:(RCTPromiseRejectBlock)reject) {
    [self connectToProtectedSSIDOnce:ssid withPassphrase:passphrase isWEP:isWEP joinOnce:false resolver:resolve rejecter:reject];
}

When connectToProtectedSSID is called without timeout, connectToProtectedSSIDOnce does not receives rejecter argument, then when user's cancels on connection prompt calling reject in connectToProtectedSSIDOnce causes crash.

My fix proposition is to remove timeout argument since it's not used on iOS implementation, thanks to that error in connectToProtectedSSIDOnce method can be reject properly and return an error to JS thread that can be properly handled.

Let me know what you think!

Remove unused timeout parameter from iOS implementation to prevent app crash
when user cancels WiFi connection prompt. This ensures proper error handling
in connectToProtectedSSID method.

Fixes JuanSeBestia#424
@DavideViolante DavideViolante merged commit e398406 into JuanSeBestia:master Jan 20, 2025
1 check passed
JuanSeBestia pushed a commit that referenced this pull request Jan 20, 2025
## [4.13.3](v4.13.2...v4.13.3) (2025-01-20)

### Bug Fixes

* **ios:** prevent crash when canceling WiFi connection ([#425](#425)) ([e398406](e398406)), closes [#424](#424)
@JuanSeBestia
Copy link
Owner

🎉 This PR is included in version 4.13.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dawidzawada dawidzawada deleted the fix/ios-cancel-crash branch January 20, 2025 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iOS: App crashes when user denies WiFi connection prompt
3 participants