All Projects ā†’ dustturtle ā†’ Realreachability

dustturtle / Realreachability

Licence: mit
We need to observe the REAL reachability of network. That's what RealReachability do.

Programming Languages

objective c
16641 projects - #2 most used programming language
ruby
36898 projects - #4 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Realreachability

Audioindicatorbars
AIB indicates for your app users which audio is playing. Just like the Podcasts app.
Stars: āœ­ 279 (-90.83%)
Mutual labels:  cocoapods, carthage
Ribbon
šŸŽ€ A simple cross-platform toolbar/custom input accessory view library for iOS & macOS.
Stars: āœ­ 273 (-91.03%)
Mutual labels:  cocoapods, carthage
Uxmpdfkit
An iOS PDF viewer and annotator written in Swift that can be embedded into any application.
Stars: āœ­ 260 (-91.45%)
Mutual labels:  cocoapods, carthage
Gemini
Gemini is rich scroll based animation framework for iOS, written in Swift.
Stars: āœ­ 2,965 (-2.53%)
Mutual labels:  cocoapods, carthage
Animoji
Animoji Generator šŸ¦Š
Stars: āœ­ 277 (-90.89%)
Mutual labels:  cocoapods, carthage
Corestore
Unleashing the real power of Core Data with the elegance and safety of Swift
Stars: āœ­ 3,254 (+6.97%)
Mutual labels:  cocoapods, carthage
Progress.swift
āŒ›ļø Add beautiful progress bars to your loops.
Stars: āœ­ 265 (-91.29%)
Mutual labels:  cocoapods, carthage
Colorizeswift
Terminal string styling for Swift.
Stars: āœ­ 253 (-91.68%)
Mutual labels:  cocoapods, carthage
Stepperview
SwiftUI iOS component for Step Indications.
Stars: āœ­ 281 (-90.76%)
Mutual labels:  cocoapods, carthage
Xcode One Dark
Atom One Dark theme for Xcode
Stars: āœ­ 273 (-91.03%)
Mutual labels:  cocoapods, carthage
Datez
šŸ“† Breeze through Date, DateComponents, and TimeInterval with Swift!
Stars: āœ­ 254 (-91.65%)
Mutual labels:  cocoapods, carthage
Passwordtextfield
A custom TextField with a switchable icon which shows or hides the password and enforce good password policies
Stars: āœ­ 281 (-90.76%)
Mutual labels:  cocoapods, carthage
Swiftytexttable
A lightweight library for generating text tables.
Stars: āœ­ 252 (-91.72%)
Mutual labels:  cocoapods, carthage
Faceaware
An extension that gives UIImageView the ability to focus on faces within an image.
Stars: āœ­ 3,004 (-1.25%)
Mutual labels:  cocoapods, carthage
reachable-url
Given an URL, it resolves as fast as possible, performing a GET without downloading the body.
Stars: āœ­ 25 (-99.18%)
Mutual labels:  ping, reachability
Yoshi
A convenient wrapper around the UI code that is often needed for displaying debug menus.
Stars: āœ­ 263 (-91.35%)
Mutual labels:  cocoapods, carthage
Simplecheckbox
A simple Checkbox
Stars: āœ­ 253 (-91.68%)
Mutual labels:  cocoapods, carthage
Localize
Localize is a framework writed in swift to localize your projects easier improves i18n, including storyboards and strings.
Stars: āœ­ 253 (-91.68%)
Mutual labels:  cocoapods, carthage
Ezswiftextensions
šŸ˜ How Swift standard types and classes were supposed to work.
Stars: āœ­ 2,911 (-4.31%)
Mutual labels:  cocoapods, carthage
Jgprogresshud
An elegant and simple progress HUD for iOS and tvOS, compatible with Swift and ObjC.
Stars: āœ­ 3,110 (+2.24%)
Mutual labels:  cocoapods, carthage

RealReachability

Version License Platform Platform

We need to observe the REAL reachability of network for iOS. That's what RealReachability do.

Why RealReachability?

As we know, we already have reachability framework for us to choose. Such as the famous repository Reachability.

BUT we really need a tool for us to get the reachability, not the local connection!

Apple doc tells us something about SCNetworkReachability API: "Note that reachability does not guarantee that the data packet will actually be received by the host."

The called "reachability" we already know can only tell us the local connection status.These tools currently we know are all supported by the SCNetworkReachability API.

Now RealReachability can do this for you~

We introduce ping module for us to check the real network status, together with SCNetworkReachability API. And we use FSM(finite state machine) to control all of the network status to confirm that only status change will be sent to application.

Enjoy it!

Quick Start With Cocoapods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like RealReachability in your projects. You can install it with the following command:

$ gem install cocoapods

Podfile

To integrate RealReachability into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

pod 'RealReachability'

Then, run the following command:

$ pod install

Installation with Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

RealReachability in your Cartfile:

github "dustturtle/RealReachability"

Manual Start

If you'd rather do everything by hand, just add the folder "RealReachability" to your project, then all of the files will be added to your project.

Dependencies

  • Xcode 5.0+ for ARC support, automatic synthesis and compatibility libraries. iOS 6.0+.
  • The SystemConfiguration Framework should be added to your project.

Usage

Start to notify(we suggest you to start notify in didFinishLaunchingWithOptions):

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [GLobalRealReachability startNotifier];
    return YES;
}

Add Observer(anywhere you like):

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(networkChanged:)
                                             name:kRealReachabilityChangedNotification
                                           object:nil];

Observer method like below:

- (void)networkChanged:(NSNotification *)notification
{
    RealReachability *reachability = (RealReachability *)notification.object;
    ReachabilityStatus status = [reachability currentReachabilityStatus];
    NSLog(@"currentStatus:%@",@(status));
}

Trigger realtime Reachability like below:

[GLobalRealReachability reachabilityWithBlock:^(ReachabilityStatus status) {
        switch (status)
        {
            case RealStatusNotReachable:
            {
            //  case NotReachable handler
                break;
            }
                
            case RealStatusViaWiFi:
            {
            //  case WiFi handler
                break;
            }
                
            case RealStatusViaWWAN:
            {
            //  case WWAN handler
                break;
            }
                
            default:
                break;
        }
    }];

Query currentStatus

ReachabilityStatus status = [reachability currentReachabilityStatus];

Once the reachabilityWithBlock was called, the "currentReachabilityStatus" will be refreshed synchronously.

Set your own host for Ping (optional)

Note that now we introduced the new feature "doublecheck" to make the status more reliable in 1.2.0!

Please make sure the host you set here is available for pinging. Large, stable website suggested.
This step is optional. If you do not set this, our default host is: www.apple.com.
You may set your own host any time you like. Codes just like below:

GLobalRealReachability.hostForPing = @"www.apple.com";
GLobalRealReachability.hostForCheck = @"www.youOwnHostExample.com";

We suggest you use two hosts: one your own(if you have one available for pinging), one public; Just like the example below.

For more details about the "doublecheck" feature, you can go deep into the codes.

Get current WWAN type (optional)

 WWANAccessType accessType = [GLobalRealReachability currentWWANtype];

Current WWAN type might be used to improve your app's user experience(e.g, set different network request timeout interval for different WWAN type).

Check the VPN status of your network

- (BOOL)isVPNOn;

With the help of this method, we have improved our reachability check logic when using VPN.

More:

We can also use PingHelper or LocalConnection alone to make a ping action or just observe the local connection.
Pod usage like blow (we have two pod subspecs):

pod 'RealReachability/Ping'
pod 'RealReachability/Connection'

This is the only API we need to invoke about Ping:

- (void)pingWithBlock:(void (^)(BOOL isSuccess))completion;

More about the ping usage, please see the PingHelper.h or codes in the demo project.

LocalConnection module is very similar with Reachability.
More about its usage, please see the LocalConnection.h or codes in the demo project.

Demo

We already put the demo project in the repository.

License

RealReachability is released under the MIT license. See LICENSE for details.

And finally...

Please use and improve! Patches accepted, or create an issue.

I'd love it if you could send me a note as to which app you're using it with! Thank you!

ę”Æꌁꈑ

老åøęœŗꊀęœÆå‘Øꊄå‡ŗ品ēš„怊WWDC å†…å‚ć€‹ē³»åˆ—ļ¼Œäø€ē›“ę˜Æ iOS 开发ēš„ē²¾å“é˜…čÆ»ļ¼Œå‡ ä¹Žę¶µē›–äŗ†ęÆå¹“éœ€č¦äŗ†č§£ēš„ę‰€ęœ‰ iOS ꖰꊀęœÆć€‚å°¤å…¶ę˜Æä»Šå¹“ć€ŠWWDC21 å†…å‚ć€‹ēš„č“Ø量ęÆ”åŽ»å¹“ęœ‰äŗ†ęÆ”č¾ƒå¤§ēš„ęå‡, 作äøŗä½œč€…ä¹‹äø€ļ¼ŒåœØčæ™é‡Œå®‰åˆ©ē»™å¤§å®¶ļ¼š https://xiaozhuanlan.com/wwdc21?rel=4203097925怂ē›®å‰ę“»åŠØä»·äŗ”ęŠ˜é”€å”®ļ¼ŒęŠ“ē“§å…„ę‰‹å•¦ć€‚

äø­ę–‡ē‰ˆä½æē”ØęŒ‡å—

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].