All Projects β†’ tonymillion β†’ Reachability

tonymillion / Reachability

Licence: bsd-2-clause
ARC and GCD Compatible Reachability Class for iOS and MacOS. Drop in replacement for Apple Reachability

Programming Languages

objective c
16641 projects - #2 most used programming language
ruby
36898 projects - #4 most used programming language
Rich Text Format
576 projects

Projects that are alternatives of or similar to Reachability

Connectivity
🌐 Makes Internet connectivity detection more robust by detecting Wi-Fi networks without Internet access.
Stars: ✭ 1,476 (-78.76%)
Mutual labels:  apple, reachability
Apfs Fuse
FUSE driver for APFS (Apple File System)
Stars: ✭ 929 (-86.63%)
Mutual labels:  apple
Rome
Carthage cache for S3, Minio, Ceph, Google Storage, Artifactory and many others
Stars: ✭ 724 (-89.58%)
Mutual labels:  apple
Openhaystack
Build your own 'AirTags' 🏷 today! Framework for tracking personal Bluetooth devices via Apple's massive Find My network.
Stars: ✭ 794 (-88.58%)
Mutual labels:  apple
Biometricauthentication
Use Apple FaceID or TouchID authentication in your app using BiometricAuthentication.
Stars: ✭ 746 (-89.27%)
Mutual labels:  apple
Appleevents
The unofficial Apple Events app for macOS
Stars: ✭ 831 (-88.04%)
Mutual labels:  apple
Hackintosh
Hackintosh long-term maintenance model EFI and installation tutorial
Stars: ✭ 6,589 (-5.19%)
Mutual labels:  apple
In App Purchase
A Node.js module for in-App-Purchase for iOS, Android, Amazon and Windows.
Stars: ✭ 868 (-87.51%)
Mutual labels:  apple
Music Web Player
Web player for Apple Music
Stars: ✭ 908 (-86.94%)
Mutual labels:  apple
Statusalert
Display Apple system-like self-hiding status alerts. It is well suited for notifying user without interrupting user flow in iOS-like way.
Stars: ✭ 809 (-88.36%)
Mutual labels:  apple
Ios Source Probe
πŸ”Ž iOS ζΊη ζŽ’ζ±‚η³»εˆ—
Stars: ✭ 807 (-88.39%)
Mutual labels:  apple
Swiftui
A collaborative list of awesome SwiftUI resources. Feel free to contribute!
Stars: ✭ 774 (-88.86%)
Mutual labels:  apple
Os X Yosemite
GTK theme based on the flat appearance of OS X 10.10 Yosemite
Stars: ✭ 17 (-99.76%)
Mutual labels:  apple
Macapps
δΈͺδΊΊζ”Άι›†ηš„δΈ€δΊ›macδ½Ώη”¨ηš„δΈζ˜“ζ‰Ύεˆ°ηš„appοΌŒδΈζ–­ζ›΄ζ–°δΈ­γ€‚
Stars: ✭ 726 (-89.55%)
Mutual labels:  apple
Runmacosinvirtualbox
Run macOS 10.16 Big Sur (and other versions) in VirtualBox on macOS
Stars: ✭ 839 (-87.93%)
Mutual labels:  apple
Sonoff Homekit
Make your Sonoff Switch compatible with Apple Homekit! πŸŽ‰
Stars: ✭ 722 (-89.61%)
Mutual labels:  apple
Visualeffectview
Dynamic blur background view with tint color (UIVisualEffectView subclass) πŸ“±
Stars: ✭ 795 (-88.56%)
Mutual labels:  apple
Mailtrackerblocker
Email tracker, read receipt and spy pixel blocker plugin for macOS Apple Mail
Stars: ✭ 821 (-88.19%)
Mutual labels:  apple
Swiftui Grid
πŸš€ SwiftUI Grid layout with custom styles
Stars: ✭ 872 (-87.45%)
Mutual labels:  apple
Awloader
AWLoader is a UI Component that allows you to integrate loader that fits your needs within your app.
Stars: ✭ 11 (-99.84%)
Mutual labels:  apple

Reference Status

WARNING there have been reports of apps being rejected when Reachability is used in a framework. The only solution to this so far is to rename the class.

Reachability

This is a drop-in replacement for Apple's Reachability class. It is ARC-compatible, and it uses the new GCD methods to notify of network interface changes.

In addition to the standard NSNotification, it supports the use of blocks for when the network becomes reachable and unreachable.

Finally, you can specify whether a WWAN connection is considered "reachable".

DO NOT OPEN BUGS UNTIL YOU HAVE TESTED ON DEVICE

BEFORE YOU OPEN A BUG ABOUT iOS6/iOS5 build errors, use Tag 3.2 or 3.1 as they support assign types

Requirements

Once you have added the .h/m files to your project, simply:

  • Go to the Project->TARGETS->Build Phases->Link Binary With Libraries.
  • Press the plus in the lower left of the list.
  • Add SystemConfiguration.framework.

Boom, you're done.

Examples

Block Example

This sample uses blocks to notify when the interface state has changed. The blocks will be called on a BACKGROUND THREAD, so you need to dispatch UI updates onto the main thread.

In Objective-C

// Allocate a reachability object
Reachability* reach = [Reachability reachabilityWithHostname:@"www.google.com"];

// Set the blocks
reach.reachableBlock = ^(Reachability*reach)
{
    // keep in mind this is called on a background thread
    // and if you are updating the UI it needs to happen
    // on the main thread, like this:

    dispatch_async(dispatch_get_main_queue(), ^{
        NSLog(@"REACHABLE!");
    });
};

reach.unreachableBlock = ^(Reachability*reach)
{
    NSLog(@"UNREACHABLE!");
};

// Start the notifier, which will cause the reachability object to retain itself!
[reach startNotifier];

In Swift 3

import Reachability

var reach: Reachability?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Allocate a reachability object
        self.reach = Reachability.forInternetConnection()
        
        // Set the blocks
        self.reach!.reachableBlock = {
            (reach: Reachability?) -> Void in
            
            // keep in mind this is called on a background thread
            // and if you are updating the UI it needs to happen
            // on the main thread, like this:
            DispatchQueue.main.async {
                print("REACHABLE!")
            }
        }
        
        self.reach!.unreachableBlock = {
            (reach: Reachability?) -> Void in
            print("UNREACHABLE!")
        }
        
        self.reach!.startNotifier()
    
        return true
}

NSNotification Example

This sample will use NSNotifications to notify when the interface has changed. They will be delivered on the MAIN THREAD, so you can do UI updates from within the function.

In addition, it asks the Reachability object to consider the WWAN (3G/EDGE/CDMA) as a non-reachable connection (you might use this if you are writing a video streaming app, for example, to save the user's data plan).

In Objective-C

// Allocate a reachability object
Reachability* reach = [Reachability reachabilityWithHostname:@"www.google.com"];

// Tell the reachability that we DON'T want to be reachable on 3G/EDGE/CDMA
reach.reachableOnWWAN = NO;

// Here we set up a NSNotification observer. The Reachability that caused the notification
// is passed in the object parameter
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(reachabilityChanged:)
                                             name:kReachabilityChangedNotification
                                           object:nil];

[reach startNotifier];

In Swift 3

import Reachability

var reach: Reachability?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Allocate a reachability object
    self.reach = Reachability.forInternetConnection()
    
    // Tell the reachability that we DON'T want to be reachable on 3G/EDGE/CDMA
    self.reach!.reachableOnWWAN = false
    
    // Here we set up a NSNotification observer. The Reachability that caused the notification
    // is passed in the object parameter
    NotificationCenter.default.addObserver(
        self,
        selector: #selector(reachabilityChanged),
        name: NSNotification.Name.reachabilityChanged,
        object: nil
    )
    
    self.reach!.startNotifier()
    
    return true
}
        
func reachabilityChanged(notification: NSNotification) {
    if self.reach!.isReachableViaWiFi() || self.reach!.isReachableViaWWAN() {
        print("Service available!!!")
    } else {
        print("No service available!!!")
    }
}

Tell the world

Head over to Projects using Reachability and add your project for "Maximum Wins!".

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].