Skip to content

Latest commit

 

History

History
131 lines (85 loc) · 3.73 KB

README.md

File metadata and controls

131 lines (85 loc) · 3.73 KB

AZReachability Notifications

Alt text

Swift version Support Dependecy Manager Version License Platform

Features

  • Simple, one method integration
  • Reachability notification on status bar and under navigation bar

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

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

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
pod 'AZReachabilityNotificatons'
end

Then, run the following command:

$ pod install

Usage

Step 1

Import AZReachabilityNotificatons module in AppDelegate.swift and just call startNetworkReachabilityObserver

import UIKit
import AZReachabilityNotificatons

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    
    let reachAbilityManager = ReachabilityManager.manager
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        
        reachAbilityManager.startNetworkReachabilityObserver(notificationType: .OnStatusBar) //enum to detrmin notification type
        
        return true
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
        reachAbilityManager.stopNetworkReachability()
    }
}

Customization

  • To show notification on status bar
    reachAbilityManager.startNetworkReachabilityObserver(notificationType: .OnStatusBar) 

And for under Navigation bar

    reachAbilityManager.startNetworkReachabilityObserver(notificationType: .UnderNavigation)
  • To have custom Strings in notification and change notification background color use this
    reachAbilityManager.internetAvailableBackgroundColor = UIColor.green // internet connectd 
    reachAbilityManager.internetNotAvailableBackgroundColor = UIColor.red // internet is not connected 


    reachAbilityManager.internetAvailableText = "Internet Connected" // internet is not connected
    reachAbilityManager.internetNotAvailableText = "No Internet Connection" // internet is not connected

Done

Thats it, you successfully integrate AZReachabilityNotificatons

Dependencies

  • Alamofire
  • CWStatusBarNotification
  • Whisper

License

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

Author

Afroz Zaheer - (https://github.com/AfrozZaheer)