Since iOS 14 there is a Local Network Permission and Apple recommends to use waitsForConnectivity
on the connection to wait for the user to answer the permission pop-up.
To check if a connection attempt is waiting for the permission Apple recommends the unsatisfiedReason
property here to check for localNetworkDenied
.
I tried to adapt Apples recommendation to Alamofire but couldn't think of anything.
My specific use case is an iOS app which connects to a server on the internet but sometimes the iOS device visits the home network of the server. For the latter it needs the permission and I want to give a good error message to the user if they revoked the local network permission (because in this case the iOS permission dialog doesn't appear again).
How can I archive this with Alamofire?
Alamofire doesn't provide a wrapper for NWPathMonitor
, which seems to be what you're talking about. You can just use it directly and start your network requests once the status changes to what you need. If you're operating at the raw network level using Network framework, Alamofire really has nothing to do here. Closest Alamofire gets is that you can use the waitsForConnectivity
property in URLSessionConfiguration
to create a custom Session
instance.