You are reading 12.6.3. See this page in 13.4.1.
Titanium.Network.BonjourBrowser
Extends Titanium.Proxy
A browser for the discovery and retrieval of Bonjour services available on the network.
Use the Titanium.Network.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:
<ti:app>
<!-- ... -->
<ios>
<plist>
<dict>
<!-- Reason to access local network-->
<key>NSLocalNetworkUsageDescription</key>
[string](api:Global.String)
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](api:Global.String)_test._tcp</string>
<array/>
</dict>
</plist>
</ios>
<!-- ... -->
</ti:app>
Properties 5
Inherited from Titanium.Proxy
The name of the API that this proxy corresponds to.
Inherited from Titanium.Proxy
Indicates if the proxy will bubble an event to its parent.
Default: true
domain
StringThe domain the browser is searching in
Default: local.
isSearching
BooleanWhether or not the browser is currently searching
Default: false
serviceType
StringThe type of the service the browser searches for
Default: null
Methods 6
Inherited from Titanium.Proxy
Adds the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to invoke when the event is fired. 4 fields
|
applyProperties
since 3.0.0Inherited from Titanium.Proxy
Applies the properties to the proxy.
| Parameters | Type | Description |
|---|---|---|
| props | Dictionary | A dictionary of properties to apply. |
Inherited from Titanium.Proxy
Fires a synthesized event to any registered listeners.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| event? | Dictionary | A dictionary of keys and values to add to the Titanium.Event object sent to the listeners. |
Inherited from Titanium.Proxy
Removes the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to remove. Must be the same function passed to 4 fields
|
Conduct a search for Bonjour services matching the type and domain specified during creation
Halt an ongoing search
Events 1
updatedservices
since 3.0.0Fired when the discovered services list is updated
| Event properties | Type | Description |
|---|---|---|
| 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. |