We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import Combine import Reachability import os class ReachabilityStore: ObservableObject { private var reachability: Reachability @Published var reachable: Bool = false @Published var reachableViaWifi: Bool = false @Published var reachableViaCellular: Bool = false init() { reachability = try! Reachability() reachability.whenReachable = { [weak self] reachability in guard let self = self else { return } self.reachable = true self.reachableViaWifi = reachability.connection == .wifi self.reachableViaCellular = !self.reachableViaWifi os_log( "Reachable via %{public}s", self.reachableViaWifi ? "WiFi" : "Cellular" ) } reachability.whenUnreachable = { [weak self] _ in guard let self = self else { return } self.reachable = false self.reachableViaWifi = false self.reachableViaCellular = false os_log("Unreachable") } do { try reachability.startNotifier() } catch { os_log("Unable to start reachability notifier.") } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: