NWPathMonitor pathUpdateHandler invoked on App Launch every time

i instantiate a NWPathMonitor when my App launches and noticed that the pathUpdateHandler is invoked every time the App is launched. i am running on a physical device and connected to WiFi at all times.

Up until now, my understanding was that pathUpdateHandler is only called when changes occur. 

Perhaps i am mistaken and this is the expected behavior.

Can anyone else confirm?

As I see it:

  • On launch, there is no path status
  • So when we get the path status, it is considered to have changed

You can always check if it has really changed in pathUpdateHandler, by comparing the new status with the previous status (which you save at the end of pathUpdateHandler).

Thanks for the reply! That makes a lot of sense. After some testing i can confirm this is indeed the behavior:

Given an uninterrupted WiFi connection, the currentPath remains .unsatisfied after the App is launched until the first invocation of pathUpdateHandler (which happens right away); it then transitions to .satisfied. The first invocation seems more like the initial state vs. a changed state.

i.e. the first invocation it is not an indication that network availability has truly changed (which was my initial assumption).

NWPathMonitor pathUpdateHandler invoked on App Launch every time
 
 
Q