It's said Bonjour browsing requires local network access. And APIs from dnssd framework will return the kDNSServiceErr_PolicyDenied error code if local access permission isn't granted.
For reference:
https://developer.apple.com/forums/thread/663852
https://developer.apple.com/forums/thread/663874
I use the code below to check the return value of bonjour browsing with permission denied.
However, the API returns 0 even if I denied the Local Network permission.
What I am expecting to see:
Browsing for Bonjour services using dns-sd API requires Local Network permission, and calling browsing API without the permission will get a kDNSServiceErr_PolicyDenied (-65570) code"
I am testing this on iOS 14.0.1 on iPhone 7 Plus.
App compiled from Xcode 12.
Could anyone point out what's wrong with my experiment code? Or it'd be greatly nice if someone could provide some sample code to actually demo how to verify the Local Network permission quickly (better in C or Objc).
Thanks!
For reference:
https://developer.apple.com/forums/thread/663852
https://developer.apple.com/forums/thread/663874
I use the code below to check the return value of bonjour browsing with permission denied.
Code Block DNSServiceRef sdRef; int result = DNSServiceBrowse(&sdRef, 0, 0, @"_kaiterra._tcp".UTF8String, NULL, dnsBrowserReply, NULL); if (result != kDNSServiceErr_NoError) { NSLog(@"DNSServiceBrowse failed with code %d", result); }
Code Block I've added the bonjour service _kaiterra._tcp to my info.plist.
However, the API returns 0 even if I denied the Local Network permission.
What I am expecting to see:
Browsing for Bonjour services using dns-sd API requires Local Network permission, and calling browsing API without the permission will get a kDNSServiceErr_PolicyDenied (-65570) code"
I am testing this on iOS 14.0.1 on iPhone 7 Plus.
App compiled from Xcode 12.
Could anyone point out what's wrong with my experiment code? Or it'd be greatly nice if someone could provide some sample code to actually demo how to verify the Local Network permission quickly (better in C or Objc).
Thanks!