@@ -19,53 +19,53 @@ import Foundation
1919import Network
2020
2121class ReachabilityHelper : NSObject {
22- private let monitor : NWPathMonitor
22+ private let monitor : NWPathMonitor
2323
24- override init ( ) {
25- monitor = NWPathMonitor ( )
26- super. init ( )
27- }
24+ override init ( ) {
25+ monitor = NWPathMonitor ( )
26+ super. init ( )
27+ }
2828
29- /**
30- * Retrieve the locale information for the app.
31- */
32- func getLocale( ) -> String {
33- return Locale . preferredLanguages [ 0 ]
34- }
29+ /**
30+ * Retrieve the locale information for the app.
31+ */
32+ func getLocale( ) -> String {
33+ return Locale . preferredLanguages [ 0 ]
34+ }
3535
36- /**
37- * Retrieve the network status for the app.
38- */
39- func getNetworkStatus( ) -> String {
40- return networkStatus ( from: monitor. currentPath)
41- }
36+ /**
37+ * Retrieve the network status for the app.
38+ */
39+ func getNetworkStatus( ) -> String {
40+ return networkStatus ( from: monitor. currentPath)
41+ }
4242
43- private func networkStatus( from path: NWPath ) -> String {
44- if path. status == . satisfied {
45- if path. usesInterfaceType ( . wifi) {
46- return " wifi "
47- } else if path. usesInterfaceType ( . cellular) {
48- return " cellular "
49- } else if path. usesInterfaceType ( . wiredEthernet) {
50- return " wired "
51- } else {
52- return " other "
53- }
54- } else {
55- return " unavailable "
56- }
43+ private func networkStatus( from path: NWPath ) -> String {
44+ if path. status == . satisfied {
45+ if path. usesInterfaceType ( . wifi) {
46+ return " wifi "
47+ } else if path. usesInterfaceType ( . cellular) {
48+ return " cellular "
49+ } else if path. usesInterfaceType ( . wiredEthernet) {
50+ return " wired "
51+ } else {
52+ return " other "
53+ }
54+ } else {
55+ return " unavailable "
5756 }
57+ }
5858
59- /**
60- * Add a hook to update network status going forward.
61- */
62- func updateAndTrackNetworkStatus( ) {
63- monitor. pathUpdateHandler = { [ weak self] path in
64- guard let self = self else { return }
65- let status = self . networkStatus ( from: path)
66- Crashlytics . crashlytics ( ) . setCustomValue ( status, forKey: " network_connection " )
67- }
68- let queue = DispatchQueue ( label: " NetworkMonitor " )
69- monitor. start ( queue: queue)
59+ /**
60+ * Add a hook to update network status going forward.
61+ */
62+ func updateAndTrackNetworkStatus( ) {
63+ monitor. pathUpdateHandler = { [ weak self] path in
64+ guard let self = self else { return }
65+ let status = self . networkStatus ( from: path)
66+ Crashlytics . crashlytics ( ) . setCustomValue ( status, forKey: " network_connection " )
7067 }
68+ let queue = DispatchQueue ( label: " NetworkMonitor " )
69+ monitor. start ( queue: queue)
70+ }
7171}
0 commit comments