# Titanium.Network.BonjourBrowser

> A browser for the discovery and retrieval of Bonjour services available on the network.

- Source: https://titaniumsdk.com/docs/sdk/12.6.4/Titanium.Network.BonjourBrowser
- Titanium SDK version: 12.6.4
- Kind: proxy
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 1.2.0
- Extends: Titanium.Proxy
- Inheritance: Titanium.Proxy

Use the [Titanium.Network.createBonjourBrowser](https://titaniumsdk.com/docs/sdk/Titanium.Network.md#createBonjourBrowser) method to create a `BonjourBrowser` instance.

If your application publishes Bonjour services itself, that service will be discovered 
by the browser if necessary; be prepared to perform a check if you do not want to list 
local services as available.  Bonjour service browsing is an asynchronous operation, 
meaning that you should be extremely careful when caching values from the `services` 
property returned by the `updatedservices` event.  In particular, if you maintain a 
local copy of available services and a user tries to connect to one, you should be prepared 
to handle failures gracefully; the next `updatedservices` event should provide the new 
services list, but you should not rely on it being delivered before user input.  When 
a window which uses Bonjour browsing is closed, if you do not want to continue searching, 
you must call the stop() method.

In iOS 14.0+, to browse services add key `NSLocalNetworkUsageDescription` and `NSBonjourServices` to the `ios plist` section of the tiapp.xml file.

Example:

``` xml
<ti:app>
  <!-- ... -->
  <ios>
    <plist>
      <dict>
        <!-- Reason to access local network-->
        <key>NSLocalNetworkUsageDescription</key>
        [string](https://titaniumsdk.com/docs/sdk/Global.String.md)
            Specify the reason for accessing the local network.
            This appears in the alert dialog when asking the user 
            for permission to access local network.
        </string>
        <!-- List of bonjour service type-->
        <key>NSBonjourServices</key>
        <array>
          [string](https://titaniumsdk.com/docs/sdk/Global.String.md)_test._tcp</string>
        <array/>
      </dict>
    </plist>
  </ios>
  <!-- ... -->
</ti:app>
```

## Properties

### domain

- Type: String
- Platforms: iPhone, iPad, macOS
- Default: `local.`

The domain the browser is searching in

### isSearching

- Type: Boolean
- Platforms: iPhone, iPad, macOS
- Default: `false`

Whether or not the browser is currently searching

### serviceType

- Type: String
- Platforms: iPhone, iPad, macOS
- Default: `null`

The type of the service the browser searches for

## Methods

### search

- Platforms: iPhone, iPad, macOS

Conduct a search for Bonjour services matching the type and domain specified during creation

### stopSearch

- Platforms: iPhone, iPad, macOS

Halt an ongoing search

## Events

### updatedservices

- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.0.0

Fired when the discovered services list is updated

Event properties:

- `services` (Array<Titanium.Network.BonjourService>): An array of BonjourService objects corresponding to currently available services. If you cache this value, including using it as table data, be aware that it could become out of date at any time due to the asynchronous nature of Bonjour service discovery.

## Inherited members

6 members are inherited. Each is documented on the type that declares it.

- [Titanium.Proxy](https://titaniumsdk.com/docs/sdk/12.6.4/Titanium.Proxy.md): `addEventListener`, `apiName`, `applyProperties`, `bubbleParent`, `fireEvent`, `removeEventListener`

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

