Latest 1.0
Homepage https://github.com/skywite/SWReachability
License MIT
Platforms ios 7.0, requires ARC
Authors

AFNetworking

Build Status
Version
License
Platform

Reachability with blocks. One line code implementation. When change network status it will go to block.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

You need to add "SystemConfiguration" frameworks into your project before implement this.

Installation

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

pod "SWReachability"

Few connection status are avaialable.


typedef NS_ENUM(NSInteger, SWNetworingReachabilityStatus) {
    SWNetworkReachabilityStatusNotReachable = 0,
    SWNetworkReachabilityStatusReachableViaWWAN = 1,
    SWNetworkReachabilityStatusReachableViaWiFi = 2,
};

Get current status

When call getCurrentNetworkStatus method it will return current status.


 if ([SWReachability getCurrentNetworkStatus] == SWNetworkReachabilityStatusNotReachable) {
        statusLbl.text = @"Connection not avaialbe.";
    }else if ([SWReachability getCurrentNetworkStatus] == SWNetworkReachabilityStatusReachableViaWiFi){
        statusLbl.text = @"Wifi is uisng";
    }else if ([SWReachability getCurrentNetworkStatus] == SWNetworkReachabilityStatusReachableViaWWAN){
        statusLbl.text = @"WWAN is uisng";
    }

Implement with notification change block

SwReachability will provide block when change notification. So few notification handeling lines will save.


[SWReachability checkCurrentStatus:^(SWNetworingReachabilityStatus currentStatus) {
        //you can get current status        

    } statusChange:^(SWNetworingReachabilityStatus changedStatus) {
        //when change status this will fire and you can identify current status

    }];

See following exmaple


[SWReachability checkCurrentStatus:^(SWNetworingReachabilityStatus currentStatus) {
        //you can get current status

        if (currentStatus == SWNetworkReachabilityStatusNotReachable) {
            notificationStatusLbl.text = @"Connection not avaialbe.";
        }else if (currentStatus == SWNetworkReachabilityStatusReachableViaWiFi){
            notificationStatusLbl.text = @"Wifi is uisng";
        }else if (currentStatus == SWNetworkReachabilityStatusReachableViaWWAN){
            notificationStatusLbl.text = @"WWAN is uisng";
        }

    } statusChange:^(SWNetworingReachabilityStatus changedStatus) {
        //when change status this will fire and you can identify current status

        if (changedStatus == SWNetworkReachabilityStatusNotReachable) {
            notificationStatusLbl.text = @"Connection not avaialbe.";
        }else if (changedStatus == SWNetworkReachabilityStatusReachableViaWiFi){
            notificationStatusLbl.text = @"Wifi is uisng";
        }else if (changedStatus == SWNetworkReachabilityStatusReachableViaWWAN){
            notificationStatusLbl.text = @"WWAN is uisng";
        }

    }];

Credits

SWReachability is owned and maintained by the SkyWite.

SWReachability was created by saman kumara ([email protected])

Security Disclosure

If you believe you have identified a security vulnerability with SWReachability, you should report it as soon as possible via email to [email protected] Please do not post it to a public issue tracker.

License

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

Latest podspec

{
    "name": "SWReachability",
    "version": "1.0",
    "summary": "Reachability with block",
    "description": "Reachability with blocks. One line code implementation. When change network status it will go to block.",
    "homepage": "https://github.com/skywite/SWReachability",
    "license": "MIT",
    "authors": {
        "saman kumara": "[email protected]"
    },
    "source": {
        "git": "https://github.com/skywite/SWReachability.git",
        "tag": "1.0"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "SWReachability/**/*",
    "resource_bundles": {
        "SWReachability": [
            "Pod/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This