1

I am using Bonjour for my iOS application. When i use

         [self.netService stop];

Service do not stop publishing. Also when i turn off the wifi

    - (void)netServiceBrowser:(NSNetServiceBrowser *) serviceBrowser didRemoveService:(NSNetService *) service moreComing:(BOOL) moreComing

this method is not getting called. for wifi Turn off i want some event from Bonjour so that i can stop other things in my app. Does any one have solution for this. Thanks in advance.

Prerna chavan
  • 3,179
  • 7
  • 35
  • 77

1 Answers1

0

Service do not stop publishing.

You can try the following:

[self.netService stop];
[self.netService removeFromRunLoop:[NSRunLoop currentRunLoop]
                 forMode:NSRunLoopCommonModes];
self.netService = nil;

Calling the stop method should invoke the delegate method netServiceDidStop, you can implement it to see if it gets called up on stopping.

for wifi Turn off i want some event from Bonjour so that i can stop other things in my app.

There seems to be no programmatic event to detect when WiFi is disabled or enabled, it's not even easily possible to detect if WiFi is currently enabled or not. You could try to check the reachability of the internet in a loop to detect when the device is offline. In this question you can find some examples how to check the reachability.

See also:

Community
  • 1
  • 1
unwichtich
  • 13,712
  • 4
  • 53
  • 66