RxWifi is reactive wrapper for Wi-Fi functionality on iOS. It allows you to connect to Wi-Fi network from your app and you can also observe various Wi-Fi changes:
- Wi-Fi is enabled on the system level
- Wi-Fi is connected to an AP
- Current connected SSID
- Current IPv4 address
- Current IPv6 address
You can simply access the RxWifi by calling RxWifi.shared.
isEnabled- flag determining if the Wi-Fi is turned on in the system settings.isConnected- flag determining if the system is currently connected to a Wi-Fi network.connectedSsid- name of the currently connected SSID (or nil if not connected).ipv4- IPv4 address (or nil if not connected).ipv6- IPv6 address (or nil if not connected).securityType- type of security of the network you want to connect to (.wep,.wpa,.eap(not supported yet)). Default.wpa.persistConfiguration- flag determining if the Wi-Fi configuration should be persisted after app finishes. Defaultfalse.changeDetectionTimeInterval- how often will the RxWifi poll for changes. Default is0.5.
connect(ssid,password)Tries to connect to Wi-Fi network with provided credentials. UsesNetworkExtensionsframework to connect (you won't be able to connect in Simulator). ReturnsObservable<ResultType>with either.successor.failure(with error).
RxWifi also provides observables accessible through rx struct:
isConnectedChanged- linked toisConnectedproperty, changes checked everychangeDetectionTimeIntervalinterval.isEnabledChanged- linked toisEnabledproperty, changes checked everychangeDetectionTimeIntervalinterval.ssidChanged- linked toconnectedSsidproperty, changes checked everychangeDetectionTimeIntervalinterval.ipv4Changed- linked toipv4property, changes checked everychangeDetectionTimeIntervalinterval.ipv6Changed- linked toipv6property, changes checked everychangeDetectionTimeIntervalinterval.
To run the example project, run pod try RxWifi.
Please note that the connect(:) method won't work Simulator since it depends on the NetworkExtensions framework. I've added IOS_SIMULATOR flag so you can at least build for Simulator.
Uses RxSwift framework. You also need to enable Hotspot configuration capability for your app.
RxWifi is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'RxWifi'Tomas Friml, instantni.med@gmail.com
RxWifi is available under the MIT license. See the LICENSE file for more info.