becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

[iOS] watch return 'null' #40

Closed EnricoGiordano1992 closed 7 years ago

EnricoGiordano1992 commented 7 years ago

I wrote this code in Ionic 2 project:

    var zeroconf = (<any>window).cordova.plugins.zeroconf;
    zeroconf.registerAddressFamily = 'ipv4'; // or 'ipv6' ('any' by default)
    zeroconf.watchAddressFamily = 'ipv4'; // or 'ipv6' ('any' by default)
    zeroconf.watch('_myservice._tcp', '.local.',
      function(result:any) {
        console.log("dev:" + JSON.stringify(result));
      },
      function(err:any){
          console.log("err: "+err)
        }
      );

This code works on Android (tested), but in iOS doesn't work (it doesn't find my device). In particular, in iOS returns "null" in failure callback. I'm using Xcode 8.3.3 and Swift 3. How can I resolve this? What version of Xcode did you use?

Many thanks!

becvert commented 7 years ago

Latest version. Do you see any error message in the xcode console? You can enable some debugging with other swift flags: -D DEBUG

EnricoGiordano1992 commented 7 years ago

I've this error:

ZeroConf: watch _myservice._tcp.local.
ZeroConf: netServiceBrowser:didNotSearch:(Function) ["NSNetServicesErrorCode": -72004, "NSNetServicesErrorDomain": 10]
2017-08-04 14:24:05.562 Ionic Conference[373:160833] err: null
becvert commented 7 years ago

it's about the dots I think. must rather be: zeroconf.watch('_myservice._tcp.', 'local.',

EnricoGiordano1992 commented 7 years ago

thank you, it works!