becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

Plugin does not request Local Network Usage Permission in iOS 14 #92

Open spragadheeshraj opened 3 years ago

spragadheeshraj commented 3 years ago

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

CoDanny commented 3 years ago

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>
jthrilly commented 3 years ago

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>
timephy commented 3 years ago

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/zeroconf@5.28.0 cordova-plugin-zeroconf@1.4.2

coloz commented 3 years ago

the same error! Thanks @CoDanny got the fix!

travisBradfield commented 2 years ago

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:

`NSBonjourServices

watch._tcp. register._tcp. unregister._tcp_
<key>NSLocalNetworkUsageDescription</key>
<string>Bonjour services</string>`
mgscox commented 2 years ago

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 => {