Skip to main content
Version: 3.x

Taro.startLocalServiceDiscovery(option)

Starts searching for the mDNS service in the LAN. The search results will be returned via the wx.onLocalService* event.

Note

  1. wx.startLocalServiceDiscovery is a performance-consuming behavior that automatically stops after 30 seconds and executes the callback function registered with wx.onLocalServiceDiscoveryStop.

  2. After calling wx.startLocalServiceDiscovery, you cannot call this API again until the search behavior stops. The operations to stop this search behavior include calling wx.stopLocalServiceDiscovery and stopping the search automatically after 30 seconds.

Reference

Type

(option: Option) => void

Parameters

Option

PropertyTypeRequiredDescription
complete(res: CallbackResult) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: CallbackResult) => voidNoThe callback function for a failed API call
success(res: CallbackResult) => voidNoThe callback function for a successful API call

FailCallbackResult

PropertyTypeDescription
errMsgstringError message

Valid values:
- 'invalid param': serviceType is empty;
- 'scan task already exist': Calls startLocalServiceDiscovery again when the current search initiated by startLocalServiceDiscovery is not stopped;

API Support

APIWeChat Mini-ProgramH5React Native
Taro.startLocalServiceDiscovery✔️