cordova-plugin-zeroconf icon indicating copy to clipboard operation
cordova-plugin-zeroconf copied to clipboard

Plugin does not request Local Network Usage Permission in iOS 14

Open spragadheeshraj opened this issue 5 years ago • 6 comments

cordova-plugin-zeroconf version 1.4.2 There is no response from .watch() method Even if the local network is enabled through some other means, the plugin calls the error callback with "null"

Platform info Cordova version 9.0.0 Cordova-ios 5.1.1 Uses WKWebview XCode 12.0.1 Ionic version 1.3.1

spragadheeshraj avatar Sep 25 '20 17:09 spragadheeshraj

This actually can be fixed with no changes to this plugin. Simply add this to your info.plist

<key>NSBonjourServices</key>
	<array>
		<string>my_service._tcp.</string>
		<string>my_other_service._tcp.</string>
	</array>
<key>NSLocalNetworkUsageDescription</key>
<string>Describe why you want to use local network discovery here</string>

CoDanny avatar Sep 30 '20 10:09 CoDanny

For those wanting a way to script this, you can add the following to your config.xml:

<config-file parent="NSBonjourServices" target="*-Info.plist">
    <array>
        <string>_my_service._tcp.</string>
    </array>
</config-file>
<config-file parent="NSLocalNetworkUsageDescription" target="*-Info.plist">
    <string>My service description.</string>
</config-file>

jthrilly avatar Oct 19 '20 12:10 jthrilly

Having the same struggle. Thanks @CoDanny got the fix!

Would be nice if this issue was documented. Finding this over google was not 100% intuitive.

Thank you for the library!

=======

Ionic: Ionic CLI : 6.12.1 (/usr/local/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/angular 5.3.5 @angular-devkit/build-angular : 0.901.12 @angular-devkit/schematics : 9.1.12 @angular/cli : 9.1.12 @ionic/angular-toolkit : 2.3.3

Capacitor: Capacitor CLI : 2.4.2 @capacitor/core : 2.4.2

@ionic-native/[email protected] [email protected]

timephy avatar Nov 07 '20 14:11 timephy

the same error! Thanks @CoDanny got the fix!

coloz avatar Mar 12 '21 09:03 coloz

Hello,

I'm battling with this issue at the moment. Please can you share the chunk from your info.plist? Mine looks like this at the moment and is not working:

<key>NSBonjourServices</key> <array> <string>watch._tcp.</string> <string>register._tcp.</string> <string>unregister._tcp_</string> </array> <key>NSLocalNetworkUsageDescription</key> <string>Bonjour services</string>

travisBradfield avatar Oct 05 '21 21:10 travisBradfield

Hi, Adding the entry to plist did not solve it for me, I had to make a slight adjusment - take note of the "dot" after _tcp in each entry, after finding comment on Apple Developer site https://developer.apple.com/forums/thread/653316?answerId=676938022#676938022

plist

        <key>NSBonjourServices</key>
	<array>
		<string>_myservice._tcp</string>
	</array>
	<key>NSLocalNetworkUsageDescription</key>
	<string>Locate server using local network discovery</string>

code Zeroconf.watch('_myservice._tcp.', 'local.').subscribe(result => {

mgscox avatar Feb 20 '22 07:02 mgscox