- Simple, one method integration
- Reachability notification on status bar and under navigation bar
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
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()
}
}
- 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
Thats it, you successfully integrate AZReachabilityNotificatons
- Alamofire
- CWStatusBarNotification
- Whisper
AZReachabilityNotificatons is available under the MIT license. See the LICENSE file for more info.
Afroz Zaheer - (https://github.com/AfrozZaheer)