mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Swift
		
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Swift
		
	
//  Copyright (c) 2018 Open Whisper Systems. All rights reserved.
 | 
						|
 | 
						|
import Foundation
 | 
						|
import Reachability
 | 
						|
import SignalCoreKit
 | 
						|
import SessionMessagingKit
 | 
						|
 | 
						|
/// **Warning:** The simulator doesn't detect reachability correctly so if you are seeing odd/incorrect reachability states double
 | 
						|
/// check on an actual device before trying to replace this implementation
 | 
						|
@objc
 | 
						|
public class SSKReachabilityManagerImpl: NSObject, SSKReachabilityManager {
 | 
						|
 | 
						|
    public let reachability: Reachability
 | 
						|
    public var observationContext: AnyObject {
 | 
						|
        return self.reachability
 | 
						|
    }
 | 
						|
 | 
						|
    public var isReachable: Bool {
 | 
						|
        return isReachable(via: .any)
 | 
						|
    }
 | 
						|
 | 
						|
    public func isReachable(via reachabilityType: ReachabilityType) -> Bool {
 | 
						|
        switch reachabilityType {
 | 
						|
        case .any:
 | 
						|
            return reachability.isReachable()
 | 
						|
        case .wifi:
 | 
						|
            return reachability.isReachableViaWiFi()
 | 
						|
        case .cellular:
 | 
						|
            return reachability.isReachableViaWWAN()
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    @objc
 | 
						|
    override public init() {
 | 
						|
        self.reachability = Reachability.forInternetConnection()
 | 
						|
    }
 | 
						|
 | 
						|
    @objc
 | 
						|
    public func setup() {
 | 
						|
        guard reachability.startNotifier() else {
 | 
						|
            owsFailDebug("failed to start notifier")
 | 
						|
            return
 | 
						|
        }
 | 
						|
        Logger.debug("started notifier")
 | 
						|
    }
 | 
						|
}
 |