Questions tagged [nwpathmonitor]
18 questions
3
votes
1 answer
Use NWPathMonitor with Swift Modern Concurrency (AsyncStream) vs GCD (DispatchQueue)
I have noticed that the start(queue:) method in NWPathMonitor requires a queue of type DispatchQueue. Is there a way to implement this using Swift Modern Concurrency, probably using AsyncStream?
Using Apple documentation for AsyncStream, I have…

logicito
- 141
- 4
3
votes
1 answer
Issue with NWPathMonitor class on internet changes
I'm using the NWPathMonitor class to check the internet changes. But I have an issue when using it. The issue is when internet is off and once it comes back, monitor.pathUpdateHandler is getting called/notifying twice. Where as in internet off case…

Jayachandra A
- 1,335
- 1
- 10
- 21
3
votes
1 answer
Why does NWPathMonitor not give a path update when the path becomes satisfied?
I have a simple class named NetworkPathMonitor that looks as follows:
class NetworkPathMonitor: ObservableObject, Cancellable {
@Published var path: NWPath? = nil
let monitor = NWPathMonitor()
init() {
…

Mark
- 16,906
- 20
- 84
- 117
3
votes
1 answer
Why network status does not get updated in swift?
I am using the new "Network" library introduced in iOS 12, but I can't figure out why the network status does not get updated to .satisfied after user gets connected.
here is the code so far:
import Network
class MapViewController: UIViewController…

Ali_C
- 215
- 3
- 11
1
vote
0 answers
How to detect the switching to different wifi networks in iOS?
I'm going through the issue in identifying network switching, let's assume I have connected to wifi-1 and then immediately switched to wifi-2.
So, here is my problem that when I'm switching to wifi-2 vice versa I'm not getting updated. To get to…

Jayachandra A
- 1,335
- 1
- 10
- 21
1
vote
0 answers
Convert NWPathMonitor into a string
This has me stumped, I am trying to get a the string of NWPathMonitor.
If I print NWPathMonitor I get this:
"satisfied (Path is satisfied), interface: en0, ipv4, dns"
How can I get the same text in a string.
let interface = NWPathMonitor() // get…

moonmonkey
- 125
- 9
1
vote
2 answers
Why doesn't path.status report the network connection status correctly in my Swift app?
I have some swift code which uses the Network framework to detect when network connectivity is available or not. If I have wifi turned on and I run my code my code reports that path.status is .satisfied and if I then turn off my wifi my code reports…

Stephen501
- 153
- 8
1
vote
2 answers
Determine network type in iOS 14 Swift 5 without Thirdparty Library
CTTelephonyNetworkInfo.currentRadioAccessTechnology is deprecated in iOS 12. so is there any api to get the network type?. we can use NWPathMonitor to know wifi, cellular, ethernet type but not 3g,4g,5g etc. Is there any complete solution for this.

SreekanthI
- 393
- 3
- 13
1
vote
1 answer
How to find out if a Wi-Fi is with or without an internet connection
I'd like to find out if a Wi-Fi has internet connection or not. Sometimes our devices are connected with Wi-Fi, but the Wi-Fi doesn't have an internet connection.
NWPathMonitor or Connectivity thirdparty. I tried it, but it is not fool proof.
I know…

CuriousMan
- 42
- 11
1
vote
0 answers
NWPathMonitor's pathUpdateHandler block is getting called on app background to foreground transition
Expected NWPathMonitor's pathUpdateHandler will get called only when there is a change in the network activity (e.g., cellular->wifi or wifi1->wifi2 or wifi->no network etc...).
What I am observing is 'pathUpdateHandler' block gets called even when…

Shiva Reddy
- 456
- 1
- 7
- 26
0
votes
0 answers
nw_path_monitor_t / NWPathMonitor: is cancelling on background / resuming on foreground necessary?
I'm using the Network.framework package on iOS to monitor for network changes. I'm using Objective C, but same underlying code as Swift NWPathMonitor. Everything is working great with code below, but curious if there's any long term lifecycle…

scosman
- 2,343
- 18
- 34
0
votes
1 answer
NWPathMonitor error when monitoring the internet connection
I'm working on a Swift app where I need to know when the device is connected to the internet or not and I implemented the following code to do that.
import Foundation
import Network
class NetworkMonitor: ObservableObject{
static let shared…

Alex Anghel
- 13
- 4
0
votes
1 answer
Why does webSocketTask.receive never complete and how do I force completion in my Swift app?
I have a Swift app that uses a web socket to download stock price information from a public API. I send a message through the socket to subscribe to various stock price changes then wait for a continuous stream of messages to be received but when I…

Stephen501
- 153
- 8
0
votes
1 answer
NSNotificationCenter posting notifications doesn't work
I have a func which uses the nw_path_monitor_t to register for network events.
// Entry point.
// Will be called from AppDelegate when app starts up
void TestNWPathMonitor () {
PrintToFile("TestingNWPathMonitor\n");
…

NightFuryLxD
- 847
- 5
- 15
0
votes
0 answers
Swift, iOS: Reachability (NWPathMonitor) vs. Ping
I'm implementing app functionality, that requires checking network reachability in a way such as:
1/ Send http request
2/ If it fails with specific kinds of error, plan to repeat request, when network is reachable
3/ When request completes…

Fedor
- 13
- 4