Vince Bartlett 1 Posted October 11, 2021 Sorry if this has been asked before but I've not been able to spot anything appropriate. My app needs to connect to the user's local network. With iOS 14 (I believe) the OS started throwing up a confirmation of allowing the app to access it. Fair enough. However if they choose to deny access, the app doesn't appear to get an an error or exception. The app has to be force terminated the restarted. Once restarted, the warning isn't displayed again but the network call just fail. Neither can I find a way to enable the query so the permission can be enabled. Anyone know of an example or description on how to handle this situation more elegantly? Thanks for any assistance. Share this post Link to post
Dave Nottage 557 Posted October 11, 2021 Do you have example code that you're using now? Share this post Link to post
Vince Bartlett 1 Posted October 12, 2021 Yep, dead easy Create a new multi device app. Add a TIdUDPClient, a text and a button to the form. Add the following to the button click handler.... procedure TForm1.Button1Click(Sender: TObject); begin try IdUDPClient1.Host := 'local_pc_name.local'; IdUDPClient1.BoundPort := 8080; IdUDPClient1.Connect; except on e: Exception do begin Text1.Text := e.Message; end; end; end; The first time that the above code is run, the confirmation box is displayed by iOS. If Allow is clicked, the call will execute as normal. If Don't Allow is selected, it all kind of hangs. If the app is terminated and rerun, then a more sensible error about can't resolve the address is received. In the real app I'm actually using an Indy HTTP client component but the way this happens is identical as far as I can determine. I'm using 10.4.2 if that makes any difference. Cheers Share this post Link to post
Dave Nottage 557 Posted October 13, 2021 Regarding UDP, please refer to: https://developer.apple.com/forums/thread/662082 As for HTTP, I'm not sure why you'd have any issues with that Share this post Link to post
Vince Bartlett 1 Posted October 13, 2021 Thanks for the reply but which protocol isn't the issue. The issue is that iOS wants the app user to confirm that they will allow the app to access local network resources. (I believe this was introduced to stop the more aggressive companies trying to create a unique user ID based on what they can sniff out on the local network for ad targeting I suppose) If the user agrees, there isn't any issue - it all works as expected. If the user chooses to deny access, there isn't an exception or error generated. The app effectively hangs and has to be force terminated. Subsequent runs of the app doesn't display the same confirmation box and all network fails as if there's no active network connection. I can't find a way to perform any check if this has happened or a way to reset the test. It's pretty crappy user experience. I guess this is pretty much as Apple intended. It's a pain there's no error reported. It's possible to change the text of the confirmation box which might be about the best I can do. Share this post Link to post