Coder Social home page Coder Social logo

rxwifi's Introduction

RxWifi

CI Status Version License Platform Swift

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

Usage

You can simply access the RxWifi by calling RxWifi.shared.

Generic properties

  • 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. Default false.
  • changeDetectionTimeInterval - how often will the RxWifi poll for changes. Default is 0.5.

Methods

  • connect(ssid,password) Tries to connect to Wi-Fi network with provided credentials. Uses NetworkExtensions framework to connect (you won't be able to connect in Simulator). Returns Observable<ResultType> with either .success or .failure (with error).

Rx observables

RxWifi also provides observables accessible through rx struct:

  • isConnectedChanged - linked to isConnected property, changes checked every changeDetectionTimeInterval interval.
  • isEnabledChanged - linked to isEnabled property, changes checked every changeDetectionTimeInterval interval.
  • ssidChanged - linked to connectedSsid property, changes checked every changeDetectionTimeInterval interval.
  • ipv4Changed - linked to ipv4 property, changes checked every changeDetectionTimeInterval interval.
  • ipv6Changed - linked to ipv6 property, changes checked every changeDetectionTimeInterval interval.

Example

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.

Requirements

Uses RxSwift framework. You also need to enable Hotspot configuration capability for your app.

Installation

RxWifi is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'RxWifi'

Author

Tomas Friml, [email protected]

License

RxWifi is available under the MIT license. See the LICENSE file for more info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.