We are developers of an app, we found that there's no LN prompt for users to install the app for the 1st time on ios18.
We used the following method to prompt the "allow/not allow" alert:
// Attempts to trigger the local network privacy alert. /// /// This builds a list of link-local IPv6 addresses and then creates a connected /// UDP socket to each in turn. Connecting a UDP socket triggers the local /// network alert without actually sending any traffic. /// /// This is a ‘best effort’ approach, and it handles errors by ignoring them. /// There’s no guarantee that it’ll actually trigger the alert (FB8711182).
func triggerLocalNetworkPrivacyAlert() { let addresses = selectedLinkLocalIPv6Addresses() for address in addresses { let sock6 = socket(AF_INET6, SOCK_DGRAM, 0) guard sock6 >= 0 else { return } defer { close(sock6) }
withUnsafePointer(to: address) { sa6 in
sa6.withMemoryRebound(to: sockaddr.self, capacity: 1) { sa in
_ = connect(sock6, sa, socklen_t(sa.pointee.sa_len)) >= 0
}
}
}
}
Here’s what I did today:
-
Using Xcode 16.2, I created a new project from iOS > App template.
-
I took the code from TN3179 and added it to my project.
-
I added a button that calls the code.
-
I ran it on an iOS 18.3.2 test device here in my office.
-
On the device, I tapped the test button. It displayed the local network alert.
So the code works in general.
As to why it’s failing in your specific case, that’s hard to say. I recommend that you repeat the steps above to confirm that they work in your environment as well. Presuming they do, you have a working case and a non-working case and you can compare the two to see where things are going wrong.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"