Post

Replies

Boosts

Views

Activity

Why NWPath.UnsatisfiedReason always return "notAvailable"
Hi! I am trying to use the NWPathMonitor to check if wifi is on or off. However the NWPath object from the monitor always has unsatisfiedReason property being "notAvailable" regardless whether I turn the wifi off or on (unsatisfiedReason doesn't change even if iPhone is connected to wifi, with NWPath.state satisfied..). Below is the simple code I tried. Can you help me to find the solution pls? Thank you! private var monitor = NWPathMonitor(requiredInterfaceType: .wifi) init() {         monitor.pathUpdateHandler = { [weak self] path in             if #available(iOS 14.2, *) {                 print(path.status)                 print(path.unsatisfiedReason)//always notAvailable                 if path.status == .satisfied {                     print("Connected to internet")                     print("Wifi is on")                 } else {                     print("No connection")                     if path.unsatisfiedReason == .wifiDenied {                         print("Wifi is off") // never execute !                     } else {                         print("Wifi is on")                     }                 }             }         }         monitor.start(queue: .global())     }     deinit {         monitor.cancel()     }
3
0
1.3k
Oct ’22
Multipeer connectivity doesn't work with bluetooth
Hi all, I'm new to Swift, I have been creating game (TicTacToe), with possibility to play through local connection (Wifi/BT) and find a good solution to use Multipeer Connectivity. In Apple Documentation is said that connection can be created throw WIfi or BT, but now I started to test my game on devices and find out that with WiFI turn on only - all works great, but with BT turn on only - nothing works(( So am I doing something wrong or multipeer connectivity these days works only with BT (then why no Apple Documentation update)? I hope you understand my issue. Thanks for any of your replies!
0
0
1.3k
Sep ’22