# onBeaconServiceChange(function callback)

Listens on Bluetooth adapter status change events
**Notice**：Notes: [startBeaconDiscovery](https://open.feishu.cn/document/uYjL24iN/uQTOuQTOuQTO/ibeacon/startbeacondiscovery) needs to be called first.

## Support

App capability | Android | iOS | PC | Harmony | Preview
---|---|---|---|---|---
Gadget | V4.6.0+ | V4.6.0+ | **X** | V7.35.0+ | Preview
Web app | V4.6.0+ | V4.6.0+ | **X** | V7.35.0+ | Preview

## Input

Parameter | Data type | Required | Default value | Description
---|---|---|---|---
callback | function | Yes | &nbsp; | Callback function of this event

## Output
Properties of return object for callback function:

Parameter | Data type | Description
---|---|---
available | boolean | Indicates whether the service is available
discovering | boolean | Indicates whether the bluetooth adapter is in searching status

##  Sample code

```js
tt.startBeaconDiscovery({
    uuids: [
        "fda50693-a4e2-4fb1-afcf-c6eb07647825"
    ],
    ignoreBluetoothAvailable: true,
    success(res) {
      tt.onBeaconServiceChange(function(res) {  
        console.log(JSON.stringify(res));  
      });
    },
    fail(res) {
      console.log(`startBeaconDiscovery fail: ${JSON.stringify(res)}`);
    }
});
```

Sample return object for the callback function:
```json
{
    "available": false,
    "discovering": true
}
```

## Error code
If a `fail` object is returned, an [errCode property](https://open.feishu.cn/document/uYjL24iN/ukzNy4SO3IjL5cjM#a825f4c8) that indicates the error code will be contained. For the error code list, refer to [Beacon API Error Code](https://open.feishu.cn/document/uYjL24iN/uQTOuQTOuQTO/ibeacon/ibeacon-api-error-code).

