Search code examples
macoscocoanetwork-programmingfirewallcode-signing

Defer network access until user allowed it


When my Mac OS application starts the first time I am getting a popup "Do you want the application ... to accept incoming network connections?". How can I get some application code executed when the user has clicked on "Deny" or "Allow"? How can I determine if the application is allowed to accept incoming network connections?

Currently my application starts sending UDP broadcast packets to discover other devices on the network before it is able to receive responses. I am using the NSApplicationDelegate method applicationDidFinishLaunching to trigger using the network. Obviously that's to early for the first application start when the firewall popup appears.


Solution

  • it's not the sandbox but the firewall. sign your app and it won't ask this question

    Do you want the application to accept incoming network connection?

    Alternatively add the proper stuff in xcode project settings to sign your app automatically when building:

    Xcode code signing guide