Skip to content

Fix iOS 17+ compatibility: Replace deprecated CNCopyCurrentNetworkInf…#144

Open
jainsuneet wants to merge 5 commits into
tripflex:masterfrom
jainsuneet:master
Open

Fix iOS 17+ compatibility: Replace deprecated CNCopyCurrentNetworkInf…#144
jainsuneet wants to merge 5 commits into
tripflex:masterfrom
jainsuneet:master

Conversation

@jainsuneet
Copy link
Copy Markdown

…o with NEHotspotNetwork

  • Replace deprecated CNCopyCurrentNetworkInfo API with NEHotspotNetwork.fetchCurrent for iOS 14+
  • Add iOS version checks (@available) to use modern APIs on iOS 14+ while maintaining backward compatibility for iOS 11-13
  • Trust NEHotspotConfigurationManager result directly on iOS 14+ (no post-connection verification needed)
  • Update getConnectedSSID() to use NEHotspotNetwork.fetchCurrentWithCompletionHandler on iOS 14+
  • Update getConnectedBSSID() to use NEHotspotNetwork.fetchCurrentWithCompletionHandler on iOS 14+
  • Add comprehensive logging to track iOS version detection and API usage
  • Add NSLocalNetworkUsageDescription entitlement requirement notes

Fixes: 'nehelper sent invalid result code [1]' error on iOS 17+

The deprecated CNCopyCurrentNetworkInfo API returns null on iOS 17+ due to privacy restrictions. This update uses the modern NEHotspotNetwork API which is the Apple-recommended replacement.

Breaking Change: None - maintains full backward compatibility with iOS 11-13

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions

Description of the Change

Alternate Designs

Why Should This Be In Core?

Benefits

Possible Drawbacks

Applicable Issues

jainsuneet and others added 5 commits May 26, 2026 13:49
…o with NEHotspotNetwork

- Replace deprecated CNCopyCurrentNetworkInfo API with NEHotspotNetwork.fetchCurrent for iOS 14+
- Add iOS version checks (@available) to use modern APIs on iOS 14+ while maintaining backward compatibility for iOS 11-13
- Trust NEHotspotConfigurationManager result directly on iOS 14+ (no post-connection verification needed)
- Update getConnectedSSID() to use NEHotspotNetwork.fetchCurrentWithCompletionHandler on iOS 14+
- Update getConnectedBSSID() to use NEHotspotNetwork.fetchCurrentWithCompletionHandler on iOS 14+
- Add comprehensive logging to track iOS version detection and API usage
- Add NSLocalNetworkUsageDescription entitlement requirement notes

Fixes: 'nehelper sent invalid result code [1]' error on iOS 17+

The deprecated CNCopyCurrentNetworkInfo API returns null on iOS 17+ due to privacy restrictions.
This update uses the modern NEHotspotNetwork API which is the Apple-recommended replacement.

Breaking Change: None - maintains full backward compatibility with iOS 11-13
Fix iOS 17+ compatibility: Replace deprecated CNCopyCurrentNetworkInf…
Fixes compilation error: 'Variable is not assignable (missing __block type specifier)'

In Objective-C, variables captured by blocks are read-only unless declared with __block.
Added __block to pluginResult declarations in:
- getConnectedSSID method
- getConnectedBSSID method

This allows the variable to be modified inside the NEHotspotNetwork completion handlers.
Merge pull request #1 from jainsuneet/fix/ios17-nehotspot-api
When user is already connected to the target network, iOS returns error code 13
(NEHotspotConfigurationErrorAlreadyAssociated). This should be treated as success,
not failure.

Changes:
- Check error code 13 and return success with SSID
- Updated both iOSConnectNetwork and iOSConnectOpenNetwork methods
- Add specific logging for 'already connected' case

Fixes issue where reconnecting to the same network throws an error instead of succeeding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant