Wifi Disconnection or Wifi to Cellular network switch callback in background

221 Views Asked by At

Can anyone please tell me if there is a way to detect when the network connection goes off when the app is in background ?

I want to get a callback when the Wifi-Network is turned off and also when there is switch from Wifi to Cellular network.

I am currently using NEHotspotHelper and I get a callback when Wifi SSID changes. i.e when the device moves from Wifi-A to Wifi-B. I also get a callback when network switches from Cellular to Wifi but not vice versa.

Please help !!

Using the below code to get callbacks.

NEHotspotHelper.register(options: nil, queue: queue, handler: {(_ cmd: NEHotspotHelperCommand) -> Void in
            network = cmd.network!
            if network.didJustJoin {

            }
        })
1

There are 1 best solutions below

0
On